craigdev
asked on
SQL Command to clone a database
How would you copy a database using SQL commands?
Of course, another way to do it would be to create a backup and then restore it as a new database.
ASKER
I want to do this from a .NET application which is why I need to figure out how to do it using SQL commands.
Do you mean to copy the data also ? In such case use BACKUP /RESTORE
Are you trying to clone the entire database, certain tables, tables with data, or just the data?
ASKER
The whole thing. I want to take a snapshot of the database at a moment in time. If my database was called DB_LIVE then a snapshot would be a functional database called DB_LIVE_20070822 which is an exact clone of the database as at today. Backup/restore would be fine but I need to send the instruction as a SQL command from the app.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Select the database, right-click, Tasks > Generate scripts. Then walk through the wizard to make your choices.
You could write all of the scripts by hand, but it would take a while.