Renaming a DataBase (MS-SQL)
September 4, 2008 Leave a comment
Check out this excellent article:
It’s not often you’ll need to rename a database, but when you do what looks like a trivial task can be complicated in a hurry. Today we’ll review the techniques used to rename a database and discuss some of the more interesting problems that can arise from renaming a database.
So why rename a database? I’d bet the most common reason is to fix a typo, or to remove an embedded space (spaces in object names are a pain). Perhaps less common would be to align the database name with a naming convention. Probably less common still is if something in the database name changes. For example, at point I worked for a company where each of our clients had their own database. It could be very confusing to tell someone to do something for customer ACME but that the data is stored in SPROCKET. In SQL 2000 it was possible to update sysdatabases directly to fix something like incorrect casing (Sprocket instead of SPROCKET) but that is not allowed in SQL 2005. If the database has been in use for a while the impact of renaming the database can be substantial, or at least seem that way! I’d suggest doing it early in the development cycle before dependences start to accrue.
