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, 2009 at 11:25 AM in Default

Steve Jones - Editor gravatar image

Steve Jones - Editor ♦♦
5.1k 78 79 82

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

1 answer: sort voted first

You would use the 'ALTER DATABASE' statement

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

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, 2009 at 11:32 AM

Kev Riley gravatar image

Kev Riley ♦♦
54.1k 47 49 76

(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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

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



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 28, 2009 at 11:25 AM

Seen: 1888 times

Last Updated: Oct 28, 2009 at 11:25 AM