TEMPDB File Movement - 05MAR15
TEMPDB File Movement - 05MAR15
STEP 1.
Determine the logical file names of the tempdb database and their current location
on the disk.
SELECT name, physical_name AS CurrentLocation
FROM sys.master_files
WHERE database_id = DB_ID(N'tempdb');
GO
STEP 2.
Change the location of each file by using ALTER DATABASE.
USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'I:\SQLData\tempdb.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'I:\SQLLog\templog.ldf');
GO
STEP 3.
Stop and restart the instance of SQL Server.
STEP 4.
Verify the file change.
FROM sys.master_files
WHERE database_id = DB_ID(N'tempdb');
STEP 5.
Delete the tempdb.mdf and templog.ldf files from the original location.