5 pts.
 How to move SQL Server databases to a new drive.
I have installed all my databases (nice_cls and nice_audit) in D:/ drive and need to move them to E:/ drive.

Software/Hardware used:
ASKED: July 9, 2009  4:20 PM
UPDATED: July 9, 2009  10:03 PM

Answer Wiki:
First, backup your databases in case something goes wrong. Then, use the sp_detach_db and sp_attach_db system procedures to detach and then attach your databases. If users are trying to connect it may help to set single user mode on the databases. After you detach the database with sp_detach_db you can move the files, then use sp_attach_db to attach them back to the SQL Server. If you want to move the system databases it is a bit more tricky, involving setting a trace flag, moving the mdf and ldf files, stopping and starting the server, and finally changing the location of the master database. There are some gotchas possible in doing this.
Last Wiki Answer Submitted:  July 9, 2009  10:02 pm  by  Denny Cherry   64,505 pts.
All Answer Wiki Contributors:  Denny Cherry   64,505 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _