Attach / detatch a database

Well we have know how to attach or detach the database in sql server through the Enterprise manager.. hmmm we have got used to it... (if any one wanna know how to do this enterprise manager then let me know)

But dear all lets do Attach / detatch of a database with sql commands:

Open the query analyzer, and enter either

To detatch the database sp_detach_db your_database_name

To attach a database sp_attach_single_file_db @dbname = 'your_database_name', @physname= 'D:\MSSQLData\data\your_database_name.mdf'

Note: The @physname is the physical path of your .mdf file.

Remarks:
The detached files remain and can be reattached using sp_attach_db or sp_attach_single_file_db. The files can also be moved to another server and attached.

Comments

Popular posts from this blog

How does dual SIM mobile work

My First Post

Nokia 7705 Twist