Thursday, August 12, 2010

Attaching detaching Databases

Attaching detaching Databases


At times, you may want to move an entire database- including all of its objects data, and log files- to another SQL server machine. To do this, SQL server enables attaching and detaching databases.

Eg: Detach

SP_DETACH_DB 'DBTEST'

Eg: Attach

SP_ATTACH_DB 'DBTEST','E:\jobin\database\DBTESTDATA.mdf','E:\jobin\database\DBTESTLOG.ldf'

No comments: