Archive for April, 2009

How to Move sql system databases

Posted: April 13, 2009 in Sqlserver


/*–Get the sqlserver database logical file names by running the below query–**/

Select name,filename from sys.sysaltfiles
/*—Put the Sqlserver in single user mode to move all the system databases.

1.Stop the sqlserver service before you put sql in single user mode
2.Open command prompt
3.Locate Binn folder
4.Run below command to put sql in single user mode



D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn>sqlservr -c -m -T3608
/*—How to move Master database in Sqlserver2005 ?
Please follow the below steps to do this
Moving the master database

Change the path for the master data files and the master log files using SQL Server Enterprise Manager for Sql2000 and for SQl2005 with the help of SCM( Sqlserver Configuration Manager).

Note You may also change the location of the error log here.

Right-click the SQL Server in SCM and then click Properties.

Goto Advance Tab

Click on Startup Parameters to see the following entries:


-d is the fully qualified path for the master database data file.

-e is the fully qualified path for the error log file.

-l is the fully qualified path for the master database log file.


Change these values as follows:
Remove the current entries for the Master.mdf and Mastlog.ldf files.
Add new entries specifying the new location:


Stop SQL Server.
Copy the Master.mdf and Mastlog.ldf files to the new location (E:\Sqldata).
Restart SQL Server.


/*—For moving MSDB database we need to even move model database.**/
–Move model database
–Detach the database

use master
sp_detach_db ‘model’

–Attach the database

Use Master
sp_attach_db ‘Model’,’D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\NewDataPath\model.mdf’,’D:\Program Files\Microsoft SQL  Server\MSSQL.1\MSSQL\NewDataPath\modellog.ldf’
–Move MSDB database
–Detach the database

use master
sp_detach_db ‘msdb’

–Attach the database
use master
sp_attach_db ‘msdb’,’D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\NewDataPath\msdbdata.mdf’,’D:\Program Files\Microsoft SQL  Server\MSSQL.1\MSSQL\NewDataPath\msdblog.ldf’




Select SERVERPROPERTY(‘Collation’) as Collation,
SERVERPROPERTY(‘BuildClrVersion’)as dotNetBuildClrVersion,
SERVERPROPERTY(‘ComputerNamePhysicalNetBIOS’)as ComputerNamePhysicalNetBIOS,
SERVERPROPERTY(‘EngineEdition’)as EngineEdition,
SERVERPROPERTY(‘InstanceName’)as InstanceName,
SERVERPROPERTY(‘IsClustered’)as IsClustered,
SERVERPROPERTY(‘IsFullTextInstalled’)as IsFullTextInstalled,
SERVERPROPERTY(‘IsIntegratedSecurityOnly’)as IsIntegratedSecurityOnly,
SERVERPROPERTY(‘IsSingleUser’)as IsSingleUser,
SERVERPROPERTY(‘MachineName’)as MachineName,
SERVERPROPERTY(‘LicenseType’)as LicenseType,
SERVERPROPERTY(‘ProcessID’)as ProcessID,
SERVERPROPERTY(‘ProductVersion’)as ProductVersion,
SERVERPROPERTY(‘ProductLevel’)as ProductLevel,
SERVERPROPERTY(‘ResourceLastUpdateDateTime’)as ResourceLastUpdateDateTime,
SERVERPROPERTY(‘ResourceVersion’)as SqlserverResourceVersion,
SERVERPROPERTY(‘ServerName’)as ServerName