Sometimes you need to move TEMPDB in SQL Server. Either because you need more space, or if you just don’t like where it is located. To do that, you need to run the following statements replacing “G:\” with the drive and directory location where you want the TEMPDB files. Once you run these statements, you must stop and restart the SQL Server service and it will create the new files. You should manually remove the old fields after you verify that the change took place.
USE master
GO
ALTER DATABASE TempDB MODIFY FILE
(NAME = tempdev, FILENAME = ‘G:\TEMPDB.MDF’)
GO
ALTER DATABASE TempDB MODIFY FILE
(NAME = templog, FILENAME = ‘G:\TEMPLOG.LDF’)
Filed under: SQL Server | Tagged: sqlserver, tempdb