Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
c.vaibhav
Starting Member
26 Posts |
Posted - 2010-03-24 : 16:32:59
|
| Hi,I want to create a database which will have all the tables and content of an existing database but with a different name.I mean there already exist a database with name "ABC" but now I want to create another with the same content as of "ABC" but with a new name "DEF".How can I do this using query?Regards,Vaibhav |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-03-24 : 16:59:48
|
| You can do it with a backup/restore.-- Create a new database backupBACKUP DATABASE AdventureWorks TO DISK = 'D:\ADW.bak'WITH INIT, STATS = 10GO-- Restore it to a different database nameRESTORE DATABASE AdventureWorks_2 FROM DISK = 'D:\ADW.bak' WITH RECOVERY, STATS = 10, MOVE 'AdventureWorks_Data' TO 'D:\SQLServer\MSSQL.1\MSSQL\Data\AdventureWorks_2_Data.mdf', MOVE 'AdventureWorks_Log' TO 'D:\SQLServer\MSSQL.1\MSSQL\Data\AdventureWorks_2.ldf'GOThere are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-03-24 : 17:01:01
|
| Don't forget to delete the backup file (in this case, 'D:\ADW.bak') when you're done with it.There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
|
|
|