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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 RESTORE vs sp_Attach_db

Author  Topic 

X002548
Not Just a Number

15586 Posts

Posted - 2003-04-28 : 15:40:10
Anyone know what order of speed difference between the 2. Also in using sp_attach_db, do you have to rename the existing database and then recreate or can you specify the existing db name.

Also any pros or cons for one over another?

Any procedural practices that anyone uses for insight would be helpful.

Thanks



Brett

8-)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-04-28 : 15:49:32
Speed difference: well sp_attach_db is much faster as compared to the RESTORE command.

From what I can remember, the database can not exist on the server where the attach is occurring, so yes you will need to rename the old one.

I do not use sp_attach_db as often as I use restore because in order to use sp_attach_db, the database file must have been released from SQL Server through sp_detach_db or by stopping the MSSQLSERVER service, which is not what we want in production. So I use the RESTORE command to copy the databases to our test/other environments. I use sp_attach_db/sp_detach_db when I want to move the database files around, perform production maintenance, and other tasks.

Tara
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2003-04-28 : 23:55:17
Also,

And this is my opinion, Backup/Restore is more trustworthy than detach/attach. I wouldn't trust taking copies of my production MDF/LDF files as a replacement for backups.

That said, detach/attach is very useful for the thing Tara listed, but not typically for disaster recovery.

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page
   

- Advertisement -