How to Move TempDB

In order to move TempDB, use the alter database command with “modify file” and specify a new path.

USE master
GO
ALTER DATABASE tempdb MODIFY file (name = tempdev, filename = 'e:tempdbtempdb.mdf')
GO
ALTER DATABASE tempdb MODIFY file (name = templog, filename = 'e:tempdbtemplog.ldf')
GO

Make sure the folder path already exist otherwise you will get an error.

Once complete, an informative message will appear stating that tempdb will be moved the next time SQL is started.

[code]

The file “tempdev” has been modified in the system catalog. The new path will be used the next time the database is started.
The file “templog” has been modified in the system catalog. The new path will be used the next time the database is started.

[/code]

This will require a restart of the SQL Server Database Engine service.

Featured Articles

 Site Author

  • Thanks for visiting!