Showing posts with label sql command. Show all posts
Showing posts with label sql 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'

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'.