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.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 best way to copy database

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2014-10-05 : 03:35:24
I want to make a copy of my database on the same sever

what is the best way to do this?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-10-05 : 04:41:15
Detach the current database.
Copy file datafile(s) and logfile(s) to new names.
Attach the first database.
Attach the copied files with the GUI (you may need to use the open file to locate the new files).



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-10-05 : 04:41:49
Or simple use the "copy database" wizard?
Right click the database in mind and follow the steps in managements studio.


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-10-05 : 16:15:57
I would recommend BACKUP/RESTORE. You would specify the WITH MOVE option and a new database name. You can use the GUI, it's the options page where you'll give the files new names.

Detach requires downtime. The copy database wizard doesn't always give you an exact copy.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Shanky
Yak Posting Veteran

84 Posts

Posted - 2014-10-08 : 09:31:03
I totally agree with Tara there is no need to shutdown SQL Server for making its copy Unless you are ok with downtime and want EXACT replica. Copy database wizard is crap and has many limitations which you can read from article:http://msdn.microsoft.com/en-GB/library/ms188664.aspx

Hope this helps

Regards
Shanky
SQL Server MVP
http://social.technet.microsoft.com/wiki/contents/articles/24253.list-of-articles-by-shanky.aspx
Go to Top of Page
   

- Advertisement -