Since these are also system databases, unfortunately we cannot move them just by detach and attach process, as we cannot attach or detach a system database.
Moving model database:
- First get the list of model database files by using this query
select name,physical_name from sys.master_files where DB_NAME(database_id)='model' - Then for each model database file that you need to move, execute statements like below
Alter Database model modify
file (NAME = 'modeldev' ,FILENAME = 'Drive:\Path\model.mdf') -- Mention the new location
Alter Database model modifyfile (NAME = 'modellog' ,FILENAME = 'Drive:\Path\modellog.ldf') -- Mention the new location
- Stop SQL Services
- Move the files manually to the new location
- Start SQL Services
- Verify the new Location
select name,physical_name from sys.master_files where DB_NAME(database_id)='model'
Moving msdb database:
- First get the list of msdb files by using this query
select name,physical_name from sys.master_files where DB_NAME(database_id)='msdb' - Then for each msdb database file that you need to move, execute statements like below
Alter Database msdb modify
file (NAME = 'MSDBData' ,FILENAME = 'Drive:\Path\MSDBData.mdf') -- Mention the new location
Alter Database msdb modifyfile (NAME = 'MSDBLog' ,FILENAME = 'Drive:\Path\MSDBLog.ldf') -- Mention the new location
- Stop SQL Services
- Move the files manually to the new location
- Start SQL Services
- Verify the new Location
select name,physical_name from sys.master_files where DB_NAME(database_id)='msdb'