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.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior 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:.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KevinAuthor Commented:

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

Kindly advise.

KevinAuthor Commented:
Please disregard i see FILENAME is a parameter.

I will apply tonight and advise of any issues.

KevinAuthor Commented:
Thanks again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.