Today, when I backed up a database and restored it to another database, I found that it could not be restored. I looked at the inconsistency between the logical File Name of the original database and the physical file name. The following method can be used to change the file name.
In the Enterprise Manager of SQL Server, it seems that you cannot directly change the database name. If you want to change the name, it is most convenient to run in the query Analyzer:
Alter database original database name
Modify name = new database name
In SQL Server, the physical file name can be changed during database restoration, or the database can be separated, and the MDF file name can be changed and appended directly. However, changing the logical file name does not seem so intuitive.
Run in the query Analyzer:
Alter database name
Modify file (name = original logical file name, newname = new logical file name)
In this way, you can change the logical file name. Because SQL Server has data files and log files, you must change the logical file names of both data files and log files, write two statements similar to the preceding statement.