SQL SERVER 2005 used to typically use sp_renamedb stored procedures.
EXEC sp_renamedb ' olddb ', ' newdb '
Or: The database is separated first, and then attached can also be renamed.
SQL SERVER 2005 also supports the storage country process for backward compatibility. It is rumored that a future version may not support the stored procedure. It is recommended that you use ALTER DATABASE MODIFY NAME.
/* Change the data name from test to Newtest */
ALTER DATABASE Test MODIFY NAME = newtest
Attention:
1. Although the database name has been modified, the database file (. mdf,.ldf) name is not modified.
2. When making database name modifications, make sure that no users are connected to the database.
--------------------------------------------------------------------------------------------------------------- ---------
--Modify the logical file name (data) of the database
ALTER DATABASE NEW MODIFY FILE (name= ' old_data ', newname= ' New_data ')
--Modify the logical file name (log) of the database
ALTER DATABASE NEW MODIFY FILE (name= ' Old_log ', newname= ' New_log ')
Favorites: SQL Server database renaming