In my database table I have two columns : ProdID and Prod. When I query the database to display the IDs and the product names, I would like to make the result a bit more 'User friendly' by changing the column names to 'Product ID and 'Product'. I do this in the following way :
Open query analyser.
Select the required database.
Select ProdID as 'Product ID', Prod as Products from Inventory
Showing posts with label Command. Show all posts
Showing posts with label Command. Show all posts
Sunday, 27 September 2009
Backup a database using a SQL command
In this example, we are backing up the database called 'Customers' to a location on the c: drive.
Backup database Customers to disk = 'c:\customer_backup.bak'
Backup database Customers to disk = 'c:\customer_backup.bak'
Get current date and time in SQL
There may be times where you will need to insert the current date and time into a database i.e. to record when a transaction has taken place. The command to display this timestamp is as follows :
select getdate() 'Current Date'
If you type this into query analyser you will get the current date and time in a column entitled 'Current Date'.
select getdate() 'Current Date'
If you type this into query analyser you will get the current date and time in a column entitled 'Current Date'.
How to create a folder with a MS-DOS command
To create a folder/directory using a DOS command, do the following :
Open up a command window i.e. Winkey + R and type cmd into the field and press Enter.
Type : md c:\Testfolder and press Enter
That's it, you will now have a folder called 'Testfolder' on your C drive !
Open up a command window i.e. Winkey + R and type cmd into the field and press Enter.
Type : md c:\Testfolder and press Enter
That's it, you will now have a folder called 'Testfolder' on your C drive !
How to merge multiple .csv files into one .txt file using command line
Create a folder on your c: drive called 'All csv files' and place all of your .csv files inside.
Open notepad and add the text below
cd C:\All csv files
copy *.csv Merged.txt
Save the text file and changed its extension to .bat 'merge.bat'.
Double click the file and you will see that a txt file is created in the C:\All csv files folder called 'Merged.txt' with all your consolidated information inside !.
Open notepad and add the text below
cd C:\All csv files
copy *.csv Merged.txt
Save the text file and changed its extension to .bat 'merge.bat'.
Double click the file and you will see that a txt file is created in the C:\All csv files folder called 'Merged.txt' with all your consolidated information inside !.
Disable a user account using command line
Access your domain contoller and type the following format to disable your user :
dsmod user "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com" -disabled yes
dsmod user "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com" -disabled yes
Check if user account is active using command line
Access your domain contoller and type the following format to check if the user is active :
NET USER jbloggs /DOMAIN | FIND /I "Account active"
NET USER jbloggs /DOMAIN | FIND /I "Account active"
Find the name of members within a group using command line
Access your domain contoller and type the following format to find the members of a group :
dsget group "cn=IT guys, ou=IT admins, dc= Your Domain name , dc=com" -members
dsget group "cn=IT guys, ou=IT admins, dc= Your Domain name , dc=com" -members
Delete a user in Active Directory using command line
Access your domain contoller and type the following format to delete your user :
dsrm "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com"
dsrm "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com"
Add a user in Active Directory using command line
Access your domain contoller and type the following format to add your user :
dsadd user "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com" -samid joebloggs -upn info@YourDomain.com -fn Joe -ln Bloggs -display "Joe Bloggs" -pwd Pa$$w0rd -desc "Systems Administrator"
*ou = is the name of Organisational Unit you will be adding the user to.
dsadd user "cn=Joe Bloggs, ou=IT Admins, dc= Your Domain name , dc=com" -samid joebloggs -upn info@YourDomain.com -fn Joe -ln Bloggs -display "Joe Bloggs" -pwd Pa$$w0rd -desc "Systems Administrator"
*ou = is the name of Organisational Unit you will be adding the user to.
How to find the size of your hard drive using a DOS command
There are other easier ways of finding the size of your hard drive but this tutorial will show you how to do it using only DOS command.
1. Open the 'run' window by going to the start menu>run (or Winkey + R).
2. Type 'cmd' and press enter and the black DOS window will open
3. Type the following to see the details for C: drive.
'fsutil volume diskfree C:'
4. You will be shown something similar to the following :
Total # of free bytes : 748716032
Total # of bytes : 69265047552
Total # of avail free bytes : 748716032
5. These numbers may be abit confusing so it is best to convert them to Gigabytes or Megabytes using a converter off the net. Here is a link to the converter i used which produced the following results :
Total # of free Mb : 714.03125
Total # of Gb : 64.5081
Total # of avail free Mb : 714.03125
1. Open the 'run' window by going to the start menu>run (or Winkey + R).
2. Type 'cmd' and press enter and the black DOS window will open
3. Type the following to see the details for C: drive.
'fsutil volume diskfree C:'
4. You will be shown something similar to the following :
Total # of free bytes : 748716032
Total # of bytes : 69265047552
Total # of avail free bytes : 748716032
5. These numbers may be abit confusing so it is best to convert them to Gigabytes or Megabytes using a converter off the net. Here is a link to the converter i used which produced the following results :
Total # of free Mb : 714.03125
Total # of Gb : 64.5081
Total # of avail free Mb : 714.03125
How to start and stop a service using command line
This method of starting and stopping a service applies to all Windows based operating systems e.g. Windows 2000, XP, Vista and Windows Server 2000/2003.
The first thing you will have to know is the name of the service you want to stop or start. You can find this by going to the services list :
1.Winkey + r
2. Type 'services.msc'
3. Locate the service you wish to start/stop and righ click>properties
4. The Service name is shown at the top on the general tab.
For my example i am going to use Internet Information Server (IIS) as the service i wish to stop. It's service name is 'w3svc'. So once you have the name then perform the following :
1. Winkey + r (or start menu and then click 'Run')
2. Type 'cmd' and press enter to bring up a command prompt.
3. Type Net Start or Net Stop (depending on what action you wish to perform) and then the service name e.g. 'Net stop w3svc'. Press enter.
4. In the above instance the command prompt window would show the messages "The World Wide Web Publishing service is stopping." and "The World Wide Web Publishing service was stopped successfully".
So, to start the service back up i would just use the Net start command.
The first thing you will have to know is the name of the service you want to stop or start. You can find this by going to the services list :
1.Winkey + r
2. Type 'services.msc'
3. Locate the service you wish to start/stop and righ click>properties
4. The Service name is shown at the top on the general tab.
For my example i am going to use Internet Information Server (IIS) as the service i wish to stop. It's service name is 'w3svc'. So once you have the name then perform the following :
1. Winkey + r (or start menu and then click 'Run')
2. Type 'cmd' and press enter to bring up a command prompt.
3. Type Net Start or Net Stop (depending on what action you wish to perform) and then the service name e.g. 'Net stop w3svc'. Press enter.
4. In the above instance the command prompt window would show the messages "The World Wide Web Publishing service is stopping." and "The World Wide Web Publishing service was stopped successfully".
So, to start the service back up i would just use the Net start command.
Saturday, 26 September 2009
How to see the names of all computers on your network with a single command
Open up a command window i.e. Winkey + R and type 'cmd' into the field and press Enter.
Type : Net View and press Enter
Type : Net View and press Enter
Open control panel items from the 'Run' window
Below are useful shortcuts to items in control panel. Just press 'Winkey + r' to pop open the run dialogue.
Type the commands in bold and the items will open.
control - Control Panel
control folders - Folder Options
control userpasswords - User Accounts
control userpasswords2 - Advanced User Accounts
control desktop - Display Properties
control printers - Printers and Faxes
control mouse - Mouse Properties
control keyboard - Keyboard Properties
control netconnections - Network Connections
control color - Display Properties \ Screensaver
control date/time - Date and Time Properties
control schedtasks - Scheduled Tasks
control admintools - Administrative Tools
control telephony - Phone and Modem Options
control fonts - Fonts Folder
control international - Regional and Language
Type the commands in bold and the items will open.
control - Control Panel
control folders - Folder Options
control userpasswords - User Accounts
control userpasswords2 - Advanced User Accounts
control desktop - Display Properties
control printers - Printers and Faxes
control mouse - Mouse Properties
control keyboard - Keyboard Properties
control netconnections - Network Connections
control color - Display Properties \ Screensaver
control date/time - Date and Time Properties
control schedtasks - Scheduled Tasks
control admintools - Administrative Tools
control telephony - Phone and Modem Options
control fonts - Fonts Folder
control international - Regional and Language
How to restart/shutdown a PC remotely using command line
This question came about when I was on my test server trying to install some software remotely, on a client laptop. I wanted to apply some changes and needed to reboot so rather than rolling the two feet to my laptop I thought "hmmm, how can I do this from here". And here's the answer ...........
Open up a run window (Winkey + R)
Type 'cmd' to open a command prompt
Type :
shutdown m \\computername -s -t : 60 (This will shutdown the PC in question after 60 seconds).
shutdown m \\computername -r -t: 60 (This will restart the PC in question after 60 seconds).
shutdown m \\computername -r -t: 0 (This will shutdown the PC immediately).
shutdown m \\computername -a (This will abort the shutdown once it is counting down)
This code can also be added to a batch file to shutdown multiple PCs all at once !
Open up a run window (Winkey + R)
Type 'cmd' to open a command prompt
Type :
shutdown m \\computername -s -t : 60 (This will shutdown the PC in question after 60 seconds).
shutdown m \\computername -r -t: 60 (This will restart the PC in question after 60 seconds).
shutdown m \\computername -r -t: 0 (This will shutdown the PC immediately).
shutdown m \\computername -a (This will abort the shutdown once it is counting down)
This code can also be added to a batch file to shutdown multiple PCs all at once !
Subscribe to:
Posts (Atom)