How to move tempdb and templog to another drive

Good Afternoon,

I am running SQL Server 2008 R2, at the moment I have my "templog.ldf" and "tempdb.mdf" being saved on the C drive.

I want to follow best practice and have these stored on a separate drive.

I have a separate drive ready for them, but don't know how to tell SQL server how to use the other drive instead of the C.

Kindly advise how I am able to do this.

Regards,
N
LVL 1
KevinAsked:
Who is Participating?
 
Scott PletcherConnect With a Mentor Senior DBACommented:
Run these commands:

ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev, FILENAME = 'X:\new\path\to\tempdb\data\tempdb.mdf' )
ALTER DATABASE tempdb MODIFY FILE ( NAME = templog, FILENAME = 'X:\new\path\to\tempdb\log\templog.ldf' )

Then stop and start SQL Server.

Then you can delete the original temp files on C:.
1
 
KevinAuthor Commented:
Thanks.

Just to confirm "FILENAME" (is the "tempdb.mdf" and "templog.ldf") or is it just the word "FILENAME"??

Kindly advise.

Regards,
N
0
 
KevinAuthor Commented:
Please disregard i see FILENAME is a parameter.

I will apply tonight and advise of any issues.

Regards,
N
0
 
KevinAuthor Commented:
Thanks again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.