If you run in situation where you need to rename your TFS Team Collection database or TFS Configuration database, there are few simple steps how to do that.

First, why would you need to rename a TFS collection database? It happened to me, that my TFS upgrade from 2008 to 2010 failed at the first run so I ended up with a database name called Tfs_DefaultCollection_1. I really couldn’t live with that suffix in my database name, so I called TFS product group for help. Here are the steps:

Renaming Team Collection database:

1. Go to the admin console and take the collection Offline

2. Once the collection is offline proceed to SQL and rename the database. This may involve taking the database offline and back online in order to release any locks on the database.

3. Come back to the Admin console and select Edit Settings for that collection

4. In the edit settings dialog there is an entry for the database name

5. Change this to the new name

6. Wait for the action to complete (might take a while since this schedules a background activity to complete the operation)

Renaming TFS Configuration database:

1.  Close the admin console (we can’t have UI open since everything is bound using the server model bound to the configdb – or at least it would add complexity)

2.  Stop the iis apppool (taking the server offline isn’t enough because we’re pulling the configdb out from under it and it’s already loaded the connection string)

3.  Rename your config db.

4.  Go to tools and run tfsconfig help registerdb.  This ultimately just edits the web.config connection string but adds some checking for you around instanceid

Keep in mind that renaming any of the databases you need to plan some TFS downtime (around 3 min for renaming my team collection database).