Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2004, 11:48 AM
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default Move SQL TempDB Database

Hi.

I originally allowed the TempDB database to be created on the C: drive. I now need to move it to the D: drive where there is more space. I tried to Detach the database so I could move it but Detach was greyed out.

How can I move this database?

Any suggestions greatly appreciated.

Rita
 
Old March 31st, 2004, 01:19 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

The first step is to open Query Analyzer and connect to your server. Once connected, you can run this script to get the names of the files used for tempdb.
use tempdb
go
sp_helpfile
go

You should see something like:
name fileid filename filegroup size
------- ------ -------------------------------------------------------------- ---------- -------
tempdev 1 C:\Program Files\Microsoft SQL Server\MSSQL\data\tempdb.mdf PRIMARY 8192 KB
templog 2 C:\Program Files\Microsoft SQL Server\MSSQL\data\templog.ldf NULL 768 KB
along with other information. Note the names of the files, usually tempdev and demplog by default. You need these names in the next statement, which will actually move the files. Suppose I wanted tempdb to move to a brand to t: drive with it's log on the u: drive. I could run the following:
use master
go
Alter database tempdb modify file (name = tempdev, filename = 't:\data\tempdb.mdf')
go
Alter database tempdb modify file (name = templog, filename = 'u:\data\templog.ldf')
go

At this point, the definition of tempdb is changed. However, since the database is rebuilt everytime SQL Server starts, there are no files to move. You stop and restart SQL Server and it will create tempdb in your new locations.


 
Old March 31st, 2004, 01:48 PM
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That did the trick. Thanks so much.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Move SQL DB from one sql to another sql server Israr SQL Server 2000 3 January 24th, 2005 02:13 PM
Help me! move database smily Oracle 3 June 27th, 2004 08:18 AM
move database to another server timbal25 Oracle 2 April 29th, 2004 08:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.