How to move system databases in SQL Server 2008



To move the model, msdb and tempdb databases:
Single user mode is no longer necessary, neither is the 3608 trace flag. Now its a simple alter command:
--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
Stop the instance, physically move the model and msdb files to the new location, and restart the instance. Tempdb files do not need to be moved as they get recreated on startup.
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:
-dE:\SQLData\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\LOG\ERRORLOG;-lE:\SQLData\mastlog.ldf
Stop the instance.
Physically move the files to the new location
Start the instance.
Moving the master database is a lot simpler because the instance no longer has to be opened in master recovery only mode, as we no longer have the ability to move the resource database. In SQL Server 2008, the location of the Resource database is :\Program Files\Microsoft SQL Server\MSSQL10.\MSSQL\Binn\. and the database cannot be moved

Comments

Popular posts from this blog

Hana XS Engine Troubleshooting

Check Users Locked or deactivated in Hana or Hana Studio

Hana ini file location