Objective
To move the SQL database .mdf and .ldf files to another drive on the server.
Environment
Primary Product OS : Windows 2012 Server
Primary Product Module : Microsoft SQL 2012
Procedure
- Launch Microsoft’s SQL Server Management Studio.
- Login to the SQL instance with an account that has the SysAdmin server role.
- Expand the folder labeled “Databases”
- Right click the database that needs the files to be moved to another location.
- Select “Properties”.
- In the Database Properties window, in the Select a page pane, click “Files”.
- “Write down” the paths and filenames that are for the database.
- Click “OK”.
- Right click the database that needs the files to be moved to another location.
- Select “Tasks => Detach…”.
- In the Detach Database window, check the box “Drop Connections”.
- Click “OK”.
- Launch Windows Explorer.
- Browse to the path you wrote down in step 7.
- “Move” the database’s files to the new location.
- “Write down” the paths where you moved the files to.
- Return to the Microsoft’s SQL Server Management Studio.
- Right click the folder labeled “Databases”
- Select “Attach…”.
- In the Attach Databases window, click “Add”.
- Browse to the path you wrote down in step 16.
- Select the .mdf filename for the database.
- Click “OK”.
- If the other files are not found, click the ellipsis next to the filename that is not found.
- In the Locate Database Files window, “browse” to the location of the file for the database that you wrote down in step 16.
- Select the file.
- Click “OK”.
- In the Attach Databases window, click “OK”.