Wednesday, May 22, 2013

How to move TempDB files to new location?

by Ashish Upadhyay

As a DBA you may need to move your tempDB location to a new directory, here is the steps to do that.


  1. Get the name of the tempdb data and log files with below command

      use tempdb
      go
     sp_helpfile 




2. Run following command

use master
go
Alter database tempdb modify file (name = tempdev, filename = 'T:\TempDB\tempdb.mdf')
go
Alter database tempdb modify file (name = templog, filename = 'T:\TempDB\templog.ldf')
go




3. Stop SQL Server service
4. Move file to the new directory. In my example I am moving files to  'T:\TempDB\'
5. Re-start your SQL Server.

Now your TempDB file has been moved to the new location.

No comments:

Post a Comment