Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

MSSQLFUN

I, Rohit Garg, am working as Consultant in IT Company. I am having an around 5 years of experience in MSSQL server & other Microsoft technologies. I am working as DBA in Microsoft SQL Server from last 5 years in e-Commerce, Telecom, Finance domain. In this tenure, I got a chance of working as Database administrator, Developer and trainer on SQL server 2000 to SQL Server 2012. I am holding Master’s degree in Computer Science along with certification in SQL Server & .Net. I like to learn new things by hand-on experience on regular basis. This journey is so far is delightful & valuable with the addition of wonderful friends.

How to change TempDB system Database files location?

Steps to change TempDB system Database files location :-

1) Check current file location of TempDB

Exec SP_helpDB TempDB

You can use below query as well for file location details.

SELECT name, physical_name AS CurrentLocation, state_desc

FROM sys.master_files

WHERE database_id = DB_ID(‘TempDB’);

2) Execute Alter Database command with Modify Filename option on Tempdb System Database

USE master

GO

ALTER DATABASE tempdb

MODIFY FILE (NAME = tempdev, FILENAME = ‘E:\SQL2K5_1\TempDB\tempdb.mdf’)

GO

ALTER DATABASE tempdb

MODIFY FILE (NAME = templog, FILENAME = ‘E:\SQL2K5_1\TempDB\templog.ldf’)

OUTPUT :-

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.

3) Restart SQL Server (TempDB automatically recreate from scratch every time SQL Server restart. To change files location, Just need to alter the file location done in step 2 & after restart SQL server will create files at new mentioned location)

4) Check file location of TempDB – After restart

5) Delete Old TempDB files from previous location to clear disk space from unused & junk files

Note : TempDB file location cannot change with deattach attach method. TempDB availability is mandatory for SQL server to come online.

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)


Comments

Leave a comment on the original post [mssqlfun.com, opens in a new window]

Loading comments...