|
This document describes how to change the location of the data and log files for any MS SQL database. There are two ways to move MS SQL databases:
Method 1
(preferrable)
- Create new MS SQL data location (E:\MSSQL\data\)
- Stop MS SQL server
- Move all databases to a new location (move *.mdf and *.ldf files)
- Create junction link between old and new MS SQL data folders. This can be done with
Sysinternals Junction or any other utility of this kind
- Start MS SQL server
In case you have some databases whith different from default locations, perform:
- Detach these databases
- Copy these databases from old location to a new location
- Attach these databases from a new location
Method 2
- Go to MS SQL Enterprise Manager
- Choose the MS SQL server Properties option. For this, go to Expand SQL Server Group->MS SQL server
<SQL Server_Name>

- On the Database Settings tab, change New database location and set the path to:
- Default data directory, i.e. a new logical disk (E:\MSSQL\DATA\)
- Default log directory (E:\MSSQL\DATA\)

- Create the following folder E:\MSSQL\DATA\
- Set the same NTFS permissions as in the folder [drive]:\Program Files\Microsoft SQL\Server\MSSQL\DATA
(the path where DB's are located ).
- Go to MS SQL Enterprise Manager->Databases and right click on the Necessary database->All tasks->Detach Database
with option Update statistics prior detach. Make sure to check database and database log files locations
before detaching a database.

- Go to [drive]:\Program Files\Microsoft SQL Server\MSSQL\DATA and copy Detached DB files (*.mdf and *.ldf) to a new folder E:\MSSQL\DATA\
- Go to MS SQL Enterprise Manager->Databases and right click on Databases->Attach Database->.

- Put the path to the necessary database (E:\MSSQL\DATA\) and select hsadmin in Specify database owner field.

- Repeat steps 6-8 for the rest of databases.
All necessary information can be found in MS SQL documentation.
|