Original link: http://www.cnblogs.com/Ryan_j/archive/2011/04/03/2004428.html
Renaming a database is simple, select the database-right--Rename the database
Or
' olddb ',' newdb '
But if you create a new database with the same name, you will get an error indicating that the database already exists.
For example, after the test database is renamed to Test1, a new database named Test will receive an error that already exists in the test database.
To the SQL Server installation directory data, you will find that test.mdf and test_log.ldf already exist. This is actually the original test1 renamed database file, we modified the database name, the database file name has not changed (or should say, test1 or test database file). Well, let's rename the database file, OK!
The database file name cannot be renamed directly because it is in use. Of course, you can stop and rename SQL Server services, and then you open SSMs should be error or let you select a database database file (so the pain of the thing I did not test, because I think this is not the appropriate method).
Or using Ryan's method, detach the database, then rename the database file, and then attach the database, for example, the data and log messages are "not found"
Then you re-select your renamed database file and log, OK.