http://www.sqlservercentral.com/blogs/ryanadams/2011/07/13/how-to-move-the-msdb-database/

Printed 2014/10/24 10:38AM

How to move the MSDB database

By Ryan Adams, 2011/07/13

First we need to know the name and file location of the MSDB database files.  When you change the location, make sure to keep the same name.  Technically we don’t need the current physical path, but it’s just a good idea to have it documented in case things go badly.

SELECT name, physical_name
FROM sys.master_files
WHERE database_id = DB_ID(N’msdb’);
GO

Next we need to tell SQL where we plan to move the files.  Make sure to change the “FILENAME” path and ensure the  ”NAME” is the same as what you got from the above query.

USE master;
GO
ALTER DATABASE msdb
MODIFY FILE (NAME = MSDBData, FILENAME = ‘Y:\MSSQL10.MSSQLSERVER\MSSQL\DATA\MSDBData.mdf’);
GO
ALTER DATABASE msdb
MODIFY FILE (NAME = MSDBLog, FILENAME = ‘Z:\MSSQL10.MSSQLSERVER\MSSQL\DATA\MSDBLog.ldf’);
GO

We need to shut down SQL.  Once SQL is stopped, copy the physical MDF and LDF to the new file system location.

Now we are ready to restart SQL server.  Once SQL is back up you might want to run the first query again just to make sure everything went as planned and the location has been updated properly.  Also, don’t forget to clean up after yourself and delete the old database files.

More Information – If you are moving your MSDB database you might want to check out the following posts:

How to move the Master database

How to move the Model database

How to move the TempDB database

SQLAgent Error 435

How to move cluster Quorum drive

How to move cluster MSDTC drive


Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.