x
login about faq Site discussion (meta-askssc)

Can I move tempdb?

My tempdb has gotten large and I am running out of disk space on the current drive. Also, I would like to separate it from the data files.

How do I move tempdb to a new drive?

more ▼

asked Oct 28 '09 at 11:25 AM in Default

Steve Jones - Editor gravatar image

Steve Jones - Editor ♦♦
5.1k 74 78 82

(comments are locked)
10|1200 characters needed characters left

1 answer: sort oldest

You would use the 'ALTER DATABASE' statement

ALTER DATABASE tempdb 
MODIFY FILE (NAME = tempdev, FILENAME = 'E:\SQLData\tempdb.mdf');
GO
ALTER DATABASE tempdb 
MODIFY FILE (NAME = templog, FILENAME = 'F:\SQLLog\templog.ldf');
GO

TempDB is recreated every time the instance of SQL Server is started, so there is no need to move the physical files. When the instance is restarted the files will be created in the locations specified.

Until then tempDB will continue to use the data and log files in the existing location. Once the instance has been restarted, you can safely delete the old files.

Further info can be found here on MSDN.

more ▼

answered Oct 28 '09 at 11:32 AM

Kev Riley gravatar image

Kev Riley ♦♦
46.1k 39 43 69

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x119
x43

asked: Oct 28 '09 at 11:25 AM

Seen: 1262 times

Last Updated: Oct 28 '09 at 11:25 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.