I'm trying to relocate system databases files.
I managed to do that with the tempdb database, but I'm stuck with msdb.
When I run:
SELECT name, physical_name AS current_file_location
FROM sys.master_files
WHERE database_id IN DB_ID('msdb')
it shows that the logical names are 'MSDBData' and 'MSDBLog'. Then when I run below mention TSQL query
alter database tempdb modify file (name = MSDBData, filename = 'C:\Data\MSDBData.mdf')
I am getting the following error: MODIFY FILE failed. File 'MSDBData' does not exist.
MS Sql 2008 R2 server version: 10.50.1600
Best Answer
First, you should use:
or
Syntax for
ALTER DATABASE
is:In your case values are as follow:
Then you can follow this procedure for MSDB:
ALTER DATABASE MSDB MODIFY FILE ( NAME = MSDBData, FILENAME = '...new path' )
ALTER DATABASE MSDB MODIFY FILE ( NAME = MSDBLog, FILENAME = '...new path' )
Check new file location
You must replace value such as MSDB, file location, file name with the correct values for your environment.