-- ####################################################################
-- Script for changing paths to physical files (mdf & ldf)
-- of the system databases (exept master).
-- Just change "D:\mdb\sys_db" to your preffered path in all strings.
-- Don`t forget to restart SQL Server proccess after execution.
-- ####################################################################

USE master;
GO

ALTER DATABASE msdb

MODIFY FILE (name = 'MSDBDATA', filename = 'D:\mdb\sys_db\MSDBDATA.mdf')

ALTER DATABASE msdb

MODIFY FILE (name = 'MSDBLOG', filename = 'D:\mdb\sys_db\MSDBLOG.ldf')

ALTER DATABASE model

MODIFY FILE (name = 'modeldev', filename = 'D:\mdb\sys_db\model.mdf')

ALTER DATABASE model

MODIFY FILE (name = 'modellog', filename = 'D:\mdb\sys_db\modellog.ldf')

ALTER DATABASE tempdb

MODIFY FILE (name = 'tempdev', filename = 'D:\mdb\sys_db\tempdb.mdf')

ALTER DATABASE tempdb

MODIFY FILE (name = 'templog', filename = 'D:\mdb\sys_db\templog.ldf')