x

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

avatar image

Steve Jones - Editor ♦♦
5.1k 79 93 87

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

1 answer: sort voted first

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

avatar image

Kev Riley ♦♦
64k 48 61 81

(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

SQL Server Central

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

Topics:

x131
x72

asked: Oct 28, 2009 at 11:25 AM

Seen: 2163 times

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

Copyright 2016 Redgate Software. Privacy Policy