Tempdb is re-created each time the instance of SQL Server is started; it’s not required to physically move the data and log files. The files are created in the new location when the service is restarted. Until the service is restarted, tempdb continues to use the existing data and log files.
1.Identify the logical file names and location of TempDB Data and Log Files
1 2 3 4 5 |
SELECT name as [logical file names], physical_name as [File location],type_desc,state_desc FROM sys.master_files WHERE database_id = DB_ID(N'tempdb'); |
2.Change the location of the .mdf and .ldf files.
Modify .mdf file location
1 2 3 |
ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = 'E:\MSSQL\tempdb.mdf'); |
Modify .ldf file location
1 2 3 |
ALTER DATABASE tempdb MODIFY FILE (NAME = templog, FILENAME = 'F:\MSSQL\templog.ldf'); |
3.Stop and restart the instance of SQL Server.
4.Verify the file change
1 2 3 4 5 |
SELECT name as [logical file names], physical_name as [File location],type_desc,state_desc FROM sys.master_files WHERE database_id = DB_ID(N'tempdb'); |
5.Delete the tempdb.mdf and templog.ldf files from the original location.
Leave a Comment