Wednesday, November 10, 2010

Detatching Files

To detatch a database
Before you can detatch a database you must make sure that all windows that connect to the database are closed.
In Management Studio, in the Object Explorer
Right click on the database
Choose "Tasks"
Choose "Detach"
Just click OK on the following dialog. Don't check any boxes.
Use the operating system file manager to navigate to the database files.
Usually they are under C:\Program Files\Microsoft SQL Server\..\mssql1\Data\
The dots are for a variable folder name. What it is depends on your installation
Copy both the .mdf and the .log file. You will need them both.
To Reattach
In Management Studio, right click on "Databases" in the Object Explorer
Choose "Attach"
In the Dialog box click "Add"
use the next dialog box to navigate to where your files are
(to attach them they must be in a "root" level folder. That means they can't be on the desktop or in my documents.)
Once you have located the files click OK.
It should reattch the database for use

No comments:

Post a Comment