How to move System database locations

Posted on Updated on

–Move Model Database
USE master;
GO
ALTER DATABASE model
MODIFY FILE (NAME = modeldev,FILENAME = ‘E:\DATA\model.mdf’);
GO
ALTER DATABASE model
MODIFY FILE (NAME = Modellog,FILENAME = ‘E:\DATA\modelLog.ldf’);
GO

–Move MSDB Database
USE master;
GO
ALTER DATABASE msdb
MODIFY FILE (NAME = MSDBData,FILENAME = ‘E:\DATA\MSDBData.mdf’);
GO
ALTER DATABASE msdb
MODIFY FILE (NAME = MSDBLog, FILENAME = ‘E:\DATA\MSDBLog.ldf’);
GO

–Move Tempdb Database
USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = ‘E:\DATA\tempdb.mdf’);
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = ‘E:\DATA\tempLog.ldf’);
GO

To move the master database:

In SQL Server configuration manager, edit the advanced properties for the SQL Server Service.

Change the startup parameters to the new location of the files, –l flag refers to log destination and –d flag refers to data file destination:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s