Learn more about SQL Server tools

   
   






















































Connect with MSSQLTips




MSSQLTips Facebook Page MSSQLTips LinkedIn Page MSSQLTips RSS Feed MSSQLTips Pinterest Page MSSQLTips Twitter Page MSSQLTips Google+ Page

Move all SQL Server system databases at one time

MSSQLTips author Greg Robidoux By:   |   Read Comments (7)   |   Related Tips: More > System Databases
Problem

One task that you may need to do as a DBA is to move the system databases from one location to another.  The documentation that is found on the Microsoft site is helpful, but the steps are more geared toward moving one database at a time.  In this tip we look at a streamlined process of moving all system databases at the same time.

Solution

There are few Microsoft KB articles that show you step by step on how to move the SQL Server system databases from one location to another location.  The steps for moving SQL Server 2000 system databases is much more convoluted than moving SQL Server 2005, 2008 or 2008R2 databases.

The following KB articles show you step by step how to move the system databases, but the process does not need to be as long as the details show.


Moving all SQL Server 2005, SQL Server 2008 or SQL Server 2008R2 System Databases

Once you have reviewed the KB articles above, you can follow these steps to move all system databases at once.

  1. Update the -d and -l startup parameters for SQL Server for the new location of the master data and log file
  2. Issue ALTER DATABASE commands to change the file location for the model, msdb and tempdb database files
  3. Stop SQL Server
  4. Move the MDF and LDF files to the new locations specified in steps 1 and 2 for the master, model and msdb databases
  5. Start SQL Server
  6. Delete the old tempdb files

In addition to the master, model, msdb and tempdb databases SQL Server 2005 introduces the mssqlsystemresource database.  Microsoft recommends not moving this database, but if you do want to move this database as well you will follow these steps.  Note you cannot move the mssqlsystemresource database for SQL Server 2008 or SQL Server 2008R2.

  1. Update the -d and -l registry startup parameters for SQL Server for the new location of the master data and log file
  2. Issue ALTER DATABASE commands to change the file location for the model, msdb and tempdb database files
  3. Stop SQL Server
  4. Move the MDF and LDF files to the new locations specified in steps 1 and 2 for the master, model and msdb databases
  5. Put SQL Server in minimal configuration mode by adding these two startup parameters -f and -T3608 and then start SQL Server
  6. Issue ALTER DATABASE commands for the mssqlsystemresource MDF and LDF files using same path as the master database
  7. Move the MDF and LDF files to the location specified in step 6 for the mssqlsystemresource database
  8. Stop SQL Server
  9. Remove the startup options added in step 5
  10. Start SQL Server
  11. Delete the old tempdb files

Moving all SQL Server 2000 System Databases

Once you have reviewed the KB articles above, you can follow these steps to move all system databases at once.

  1. Update the -d and -l startup parameters for SQL Server for the new location of the master data and log file
  2. Issue ALTER DATABASE commands to change the file location for the tempdb database files
  3. Stop SQL Server
  4. Move the MDF and LDF files to the new location specified in steps 1 for the master database
  5. Put SQL Server in single user mode by adding these three startup parameters -c, -m and -T3608 and then start SQL Server
  6. Detach the msdb and model databases
  7. Move the MDF and LDF files to the new location for the model and msdb databases
  8. Attach the model database from its new location
  9. Stop SQL Server
  10. Remove the startup options added in step 5
  11. Start SQL Server
  12. Attach the msdb database
  13. Delete the old tempdb files

Although it still seems like a lot of steps this will cut down on the need to stop and start SQL Server as much if you move one database at a time.  As you can see moving all of the databases for SQL Server 2005, 2008 and 2008R2 is much easier than moving the databases for SQL Server 2000 especially if you do not move the mssqlsystemresource database.

Next Steps


Last Update: 9/5/2011


About the author
MSSQLTips author Greg Robidoux
Greg Robidoux is the President of Edgewood Solutions and a co-founder of MSSQLTips.com.

View all my tips
Related Resources


print tip Print  
Become a paid author





join MSSQLTips for free SQL Server tips     



Learn more about SQL Server tools
Post a comment or let the author know this tip helped you.

       All comments are reviewed, so stay on subject or we may delete your comment.

*Name   *Email Notify for updates



       Note: your email address is not published. Required fields are marked with an asterisk (*)


Get free SQL tips:

*Enter Code refresh code     



Thursday, December 12, 2013 - 5:57:59 PM - Greg Robidoux Read The Tip

Hi adame, take a look at this article.  I think this is what you are looking for: http://yrushka.com/index.php/database-recovery/sql-server-migration-from-one-server-to-another-detailed-checklist/

 


Thursday, December 12, 2013 - 12:43:21 PM - adame Read The Tip

Greg-

Thanks for the response.  The new server is still in the box to add but looking to move and upgrade the whole SQL 2008 environment.


Wednesday, December 11, 2013 - 3:19:33 PM - Greg Robidoux Read The Tip

Hi Adame,

are you referring to moving the user databases or the system databases to the new server?


Wednesday, December 11, 2013 - 2:38:46 PM - adame Read The Tip

I am upgrading from SQL 2008 to SQL 2008 R2 and also moving the database to a brand new server as well.  Is it best to upgrade the old server to 2008 r2 first or can this be done in one process?

 


Thursday, April 29, 2010 - 4:56:01 PM - admin Read The Tip

I jusr came across this for SQL 2008

http://msdn.microsoft.com/en-us/library/ms345408.aspx 

Moving the Resource Database


In SQL Server 2008, the location of the Resource database is <drive>:\Program Files\Microsoft SQL Server\MSSQL10.<instance_name>\MSSQL\Binn\. The database cannot be moved.

 

For SQL 2005 I am pretty sure you need to do use the ALTER DATABASE command.


Thursday, April 29, 2010 - 1:12:31 PM - wshawnmelton Read The Tip

The only thing required to move the Resource database is to copy the MDF and LDF files to the same location of the master.mdf file.  The alter database command does not have to be executed against that database, and I don't believe you can execute it against that database.

 http://msdn.microsoft.com/en-us/library/ms190940%28SQL.90%29.aspx


Wednesday, March 03, 2010 - 4:29:02 PM - MikeL Read The Tip

 I have a sql server 2005 64 bit 2 node cluster. I tried to move master following actually a page that you reference and all works until I attempt to move the resource database. I stop sql server service from configuration manager and then run:

 D:\>NET START MSSQLSERVER /f /T3608
The SQL Server (MSSQLSERVER) service is starting.
The SQL Server (MSSQLSERVER) service was started successfully.

 

Next I try to log in using sqlcmd I get this:

D:\>D:\MSSQL\90\Tools\binn\sqlcmd.exe -sMSSQLSERVER
HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi
shing a connection to the server. When connecting to SQL Server 2005, this failu
re may be caused by the fact that under the default settings SQL Server does not
 allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

 

Now I have done used the instructions on moving sql server user and system databases on a non-clustered environment to test without this issue. I am thinking that I need to start sql server in a cluster differently but how do I get these recommended flags as part of the service startup? Using net start seems to have an issue when in a cluster.




 
Sponsor Information