if SQL Server 2005 can be directly renamed, but SQL Server 2000 cannot be changed directly, you can use Sp_renamedb.
1. Method One (physical law): change old database to new database open "Enterprise Manager" find old database--"right--" All Tasks--"detach the database and then to C:\Program Files\Microsoft SQL Server\mssql\ Under Data, find Old_data.mdf and old_log.ldf to replace Old_data with your desired name such as New.mdf, New.ldf and then to Enterprise Manager, find the database--"right--" All Tasks--"Additional database--" In the pop-up dialog, find the file you renamed New.mdf this time you can see "the original Database file name" "Current file Location", before "current file location" There will be a red X, and then manually modify the "Current file location" in the path of the file name, changed to New.mdf,new.ldf, The red X disappears, "in Attach as:" Write the database name you want to use new, "Specify database owner:" Write the owner of this database, if it is wrong, it is difficult to change later (at least the general people find it difficult to change). OK, fix it. Previously written to this point, as if the customer did not say anything, feeling should be able to, but today found this problem: Although the current database file name shows the "New" we want, but at this time the logical file name has not been modified, or the original "Old_date", open Enterprise Manager-" On this database point right-click on the property-"Data file," the current database location path before the file name or the original, the file name under the thing log is also the previous file name, that is not completely successful, so we have to act as follows-"tool-" SQL Query Analyzer--" Then type: Alter DataBASE New MODIFY FILE (name=' Old_data ', newname=' New_data 'Alter DataBASE New MODIFY FILE (name=' Old_log ',Newname=' New_log ')--"press F5 to run." OK, generally also to the user to set the space size, set up on it. 2. Method Two (Stored procedure method): Sp_renamedb change the name of the database.
Syntax sp_renamedb [@dbname =] ' Old_name ', [@newname =] ' new_name '
parameter [@dbname =] ' old_name '
is the current name of the database. Old_name is a sysname type with no default value.
[@newname =] ' New_name '
is the new name of the database. New_name must follow the rules for identifiers. New_name is a sysname type with no default value.
Return code value 0 (succeeded) or not 0 digits (failed)
Permissions only members of the sysadmin and dbcreator fixed server roles can perform sp_renamedb.
Example the following example renames the database accounting to financial.
EXEC sp_renamedb ' accounting ', ' financial '
SQL server2000 Change database name