Toss SQL SERVER 2012, get a morning to modify the database name, mainly need to modify the name of Db.mdf and Db_log.ldf, finally solved. Write it down here, and change it later, and don't forget it.
Assuming the original database name is DB, the attached database is db.mdf and db_log.ldf.
Need to be changed to DBT, and Dbt.mdf and Dbt_log.ldf.
Steps:
1. First make a backup of the original database (choose Database--right----------), back up the Db.bak file.
2. Right-click the task---restore database, and jump out of the Restore Database window.
3. Select "Source Device", browse, jump out "Specify Backup" dialog box, click Add to find the Db.bak file just backed up, OK.
4. In the Restore Database window, select the backup set for restore to tick the backup set.
5. Select "File" in the "Options page", "Specify the path after the restore and the name Dbt.mdf and dbt_log.ldf (directly change the name)
OK, that is, the modification of the name is completed.
6. Change the physical name of the database file, the physical name of the transaction log
Open SQL Query Analyzer and enter the following code;
ALTER Database name MODIFY file (name= ' current database file physical name ', newname= ' database physical name to change ')
ALTER DATABASE DBT MODIFY FILE (name= ' db ', newname= ' DBT ')
ALTER DATABASE DBT MODIFY FILE (name= ' db_LOG ', newname= ' Dbt_log ')
SQL SERVER modifies the database name (including modification of the db.mdf name)