On my current project, we’ve been running out of disk space on our development servers. The culprit is SQL Server’s tempdb. During installation, it was left on the c: drive, which is of course our smallest disk. User databases can easily be moved via detach/attach, but this doesn’t work for the tempdb. To move the tempdb, another solution exists. First, use
use tempdb
go
sp_helpfile
go
to see where the tempdb files are located at the moment (you’ll need this path in a moment). Move them to another place with
use master
go
Alter database tempdb modify file (name = tempdev, filename = 'd:\databases\tempdb.mdf')
go
Alter database tempdb modify file (name = templog, filename = 'e:\database_logs\templog.ldf')
go
and restart SQL Server. However, I noticed that even after the restart, the c: disk was still being used for the tempdb! The solution turned out to be to delete the tempdb.mdf and templog.ldf files on the c: disk (see the paths returned by sp_helpfile before the move).
October 24, 2006 at 4:25 pm
[...] and restart SQL Server. However, I noticed that even after the restart, the c: disk was still being used for the tempdb! The solution turned out the delete the tempdb.mdf and templog.ldf files on the c: disk (see the paths returned by sp_helpfile before the move). Posted by stevendI was very impressed by this post. Hope to see more stuff from author.Link to original article [...]
August 7, 2007 at 10:34 pm
Thanks for the short and sweet code bits to change the tempdb location.
It took 5 minutes to do the change what I got a straight answer.
Thanks,
Steve
April 16, 2008 at 6:29 pm
To execute within the Management studio, I had to use double quotes. Good tip!
use master
go
Alter database tempdb modify file (name = tempdev, filename = “e:\databases\tempdb.mdf”)
go
Alter database tempdb modify file (name = templog, filename = “e:\database_logs\templog.ldf”)
go
February 28, 2011 at 1:52 pm
I didn’t have to use double quotes for Filename in ALter database tempdb…
November 12, 2011 at 9:21 pm
Chattanooga Web Hosting…
[...]Move SQL Server 2005 TempDB « Only Talking Sense[...]…