Welcome to MSDN Blogs Sign in | Join | Help

Changing what drive TFS databases are on

I got a question recently about how to change what drive the TFS SQL databases are installed on.  It seemed like a question many people might want the answer to, so I decided to post about it.

The first thing the poster noticed was that they changed the default database location in SQL Server Management Studio and it had no effect on where the TFS databases were created when he installed TFS.  This is because that setting is a UI setting for SQL Server Management Studio only and does not affect where databases are programatically created (using the CREATE DATABASE TSQL statement).

The recommended way to do this is to let TFS create the databases on the default drive and then go back and move them after the fact.

a.       Install TFS

b.      Stop the AT - you can use iireset /stop

c.       Detach all TFS databases (and log files) - Using the Object Explorer in SQL Management Studio, right click on the database and choose Tasks -> Detach

d.    Copy them to a new location

e.      Attach the databases - Using the Object Explorer in SQL Management Studio, right click on "Databases" and choose Attach.

f.      Restart the AT - you can use iisreset /start

If you absolutely must change the drive that the TFS databases are initially created on, you can do it but it is not for the feint of heart:

You can do it by relocating the model system database as it is used as the template on database creation. The steps for that would be something like the following.  I'd recommend you consult your SQL Server documentation if you really plan on attempting this.

a. Run

  • alter database model
  • modify file (name=modeldev, filename=’<new path>\model.mdf')

b. Restart SQL Server

c. Run TFS setup – databases will be created in @newpath.

Keep in mind that a change to model, will affect all future database creations.

Brian

Published Tuesday, December 18, 2007 8:45 AM by bharry
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Geek Lectures - Things geeks should know about &raquo; Blog Archive &raquo; Changing what drive TFS databases are on

# re: Changing what drive TFS databases are on

There is always a lot easier way to move the files to other places. Using FAR Manager (only tool I know to be able to do that) you can create symbolic links - stop services (or detach/bring offline), move folder/files to another place, create symlink to original place, start service. Its an absolutely safe technique, I have used it a lot with MSSQL and Virtual Server.

Wednesday, December 19, 2007 10:30 AM by Knaģis

# re: Changing what drive TFS databases are on

Wednesday, December 19, 2007 5:04 PM by Maor David-Pur

# VSTS Links - 12/20/2007

Dajung on Determining Code Complexity. Michael Ruminer on TFS Admin Tool on Codeplex. Tim Hibbard on...

Thursday, December 20, 2007 7:35 AM by Team System News

# re: Changing what drive TFS databases are on

I definitely agree the first one is a lot easier and mostly like the only method supported by the DBAs that control the machines. In smaller environments where I get to act as my own DBA or I have some undo sawy with the database person(s) I do something similar to #2 except I go into the properties of the SQL Server instance and change the default database. Do the install and change the default location back. But all in all it's just as easy and less noise from others to simply detach/attach for a move.

It seems most larger organization are clustered and with SANs and filegroups etc. and after the install the powers that be rearrange to fit their own practices - such as where the datawarehouse lives.

Thursday, December 20, 2007 8:25 AM by Michael Ruminer

# re: Changing what drive TFS databases are on

Forgive my ignorance - but what does "AT" stand for in "Stop the AT".

Tuesday, January 15, 2008 3:07 PM by tfs user

# re: Changing what drive TFS databases are on

It stands for Application Tier - the TFS web services.

Brian

Tuesday, January 15, 2008 3:13 PM by bharry

# re: Changing what drive TFS databases are on

I ended up changing this registry entry and set the default directory and log file location.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer

I think this is the same as setting it on the server properties/database settings dialog.

Remember to restart the service!

Wednesday, January 16, 2008 2:54 PM by tfs user

# re: Changing what drive TFS databases are on

I wasn't clear in my earlier post, changing the registry entry (or using the SMS) default directory does work to change the install directory for databases created with SQL script but you must remember to start and stop the service.  My TFS databases were installed correctly on drive D:, no attach/detach was required.

Wednesday, January 23, 2008 9:30 AM by tfs user

# 【日本語版】 TFS のデータベースが入っているドライブを変更する

こんにちは! 鈴木裕子の投稿を読みながら、早く Windows 7 を試してみたくてウズウズしている、フォーラム オペレーターの服部清次です。 ^o^ 今日も、昨日に引き続き、 MSDN フォーラムの

Monday, January 19, 2009 8:05 PM by Microsoft Japan Forum Operators Blog

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker