Move SQL Server tempdb to Another Location

Step 1. List out the tempdb configuration and location.

USE tempdb 
GO 
EXEC sp_helpfile 
GO
tempdev   1         C:\TEMPDB\tempdb.mdf          PRIMARY   307200 KB Unlimited 10%       data only
templog   2         C:\TEMPDB\templog.ldf         NULL      61440 KB  Unlimited 10%       log only

Step 2. On the another location, ensure you have create the directory structure for the tempdb. Execute below command.

USE master 
GO 
ALTER DATABASE tempdb 
MODIFY FILE (NAME = tempdev, FILENAME = 'C:\temptest\tempdb.mdf') 
 
GO 
ALTER DATABASE tempdb 
MODIFY FILE (NAME = templog, FILENAME = 'C:\temptest\tempdb.ldf') 
GO
The file "tempdev" has been modified in the system catalog. 
The new path will be used the next time the database is started.

Step 3. Restart the SQL Server service and you will see the updated tempdb now.

You May Also Like

Leave a Reply?