What is the correct procedure to rename a database?
Example: I have a database that I can access with SQL Server Management Studio and has a name like \"MyDatabase\". Ph
Once the file names have been changed you can’t use the GUI for the re-attach
CREATE DATABASE MyAdventureWorks
ON (FILENAME = 'C:\MySQLServer\AdventureWorks_Data.mdf'),
(FILENAME = 'C:\MySQLServer\AdventureWorks_Log.ldf')
FOR ATTACH;
Refresh your SSMS and you are all done.
References
Note: If you prefer to type as little code as possible. Once the database is detached, use the GUI to begin the re-attach process before you change the file names. Use the "Script Action to..." and get the code. After changing the file names with windows explorer, update them in the code in SSMS and run it.