Favorites: SQL Server database renaming

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.