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 '09 at 11:25 AM in Default

Steve Jones - Editor gravatar image

Steve Jones - Editor ♦♦
5.1k 76 79 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 ♦♦
50.8k 43 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

By RSS:

Answers

Answers and Comments

SQL Server Central

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

Topics:

x124
x49

asked: Oct 28 '09 at 11:25 AM

Seen: 1577 times

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