Sessions: 39 The postings on this site are my own and do not represent my Employer's positions, advice or strategies.


  Saturday, July 20, 2024
Wider View Login

IBM - AS400
Performance Counters
Service Broker
SQL Server
     Temporary Database
          Compressed Backups
          Moving the master an...
          Start SQL Server and...
          SQLAgent Job Waiting...
     SQL Mail
     DTS - Data Transformation Services
     Jobs SQL Agent
     User Management
     System Databases
     Temp Tables
Windows OS

Will be added as a sub-category of, Backup
Moving the master and Resource Databases

Moving the Master and Resource Databases - SQL Server 2005 ONLY, the procedure has changed with SQL2008, specifically the resource database CAN NOT BE MOVED, look in books online.

  1. From the Start menu, point to All Programs, point to Micrsoft SQL Server 2005, point to Configuration tools, and then click SQL Server Configuration Manager.
  2. In the SQL Server 2005 Services node, right-click the instance of SQL Server (for example, SQL Server (MSSQLSERVER)) and choose Properties.
  3. In the SQL Server (Instance name) Properties dialog box, click the Advanced tab
  4. Edit the Startup Parameters values to point to the planned location for the master database data and log files, and clikc OK, Moving the error log file is optional.
    The parameter value for the data file must follow the -d parameter and the value for the log file must follow the -l parameter.  The following examples shows the parameter values for the default location of the master data and log files.
    -dC:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG;-lC:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf
    If the planned relocation for the master data and log files is E:\SQLData, the parameter values would be changed as follows:
    -dE:\SQLData\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG;-lE:\SQLData\mastlog.ldf
  5. Stop the instance of SQL Server by right-clicking the instance name and choosing Stop.
  6. Move the master.mdf and mastlog.ldf files to the new location.
  7. Start the instance of SQL Server in master only recovery mode by entering one of the following commands at the command prompt.  The parameters specified in these commands are case sensitive.  The command fail when the parameters are not specified as shown.
    • For the default (MSSQLSERVER) instance, run the following command.
    • For a named instance, run the following command.
    NET START MSSQL$instancename /f /T3608
  8. Using sqlcmd command or SQL Server Management Studio, run the following statements.  Change the FILENAME path to match the new location of the master data file.  do not change the name of the database or the file names.
    ALTER DATABASE mssqlsystemresource MODIFY FILE (NAME=data, FILENAME= 'new_path_of_master\mssqlsystemresource.mdf');
    ALTER DATABASE mssqlsystemresource MODIFY FILE (NAME=log, FILENAME= 'new_path_of_master\mssqlsystemresource.ldf');
  9. Move the mssqlsystemresource.mdf and mssqlsystemresource.ldf files to the new location.
  10. Set the Resource database to read-only by running the following statement:
    ALTER DATABASE mssqlsystemresource SET READ_ONLY
  11. Exit the sqlcmd utility or SQL Server Management Studio.
  12. Stop the instance of SQL Server
  13. Restart the instance of SQL Server
  14. Verify the file change for the master database by running the following query.  The Resource database metadata cannot be viewed by using the system catalog views or system tables.
    SELECT name, physical_name AS CurrentLocation, state_desc
    FROM sys.master_files
    WHERE database_id = DB_ID('master');
  15. Done