SQL Server Backup restores database times usage errors

Source: Internet
Author: User

1, do the project encountered this situation : The original Test_dev database, want to copy out test_ft for testing purposes. At this time backup Test_dev out Test_backup file, want to directly revert to TEST_FT will report the use of errors.

Restore DATABASE: The backup set holds a backup of a database other than the existing database cannot gain exclusive access to the database because it is in use

2, Reason: (1) The backup file contains the original database and file name information, the default will be restored to the Test_dev database, and file file is still test_dev.mdf and test_dev_log.ldf files. Test_ft and its files already exist in the server and folder, so the database and file occupancy conflicts will occur.

(2) If the database name and file file name are modified to test_ft, the test_ft restore succeeds, and the original Test_dev database is always in the restored state

3. Solutions

Scenario One: (1) detach the Test_dev database or take it offline

(2) Do not need to create test_ft database in advance, directly restore, the database name is changed to Test_ft, the corresponding file name is changed to Test_ft.mdf and Test_ft_log.ldf

(3) Additional or online Test_dev

Scenario Two: (1) do not need to create test_ft database in advance, directly restore, the database name is changed to Test_ft, the corresponding file name is changed to Test_ft.mdf and Test_ft_log.ldf

(2) In this case, unfortunately, cause 2, delete the Test_dev library

(3) Restore the Test_dev library again

4, attached: The general situation of the database is occupied by the processing method

Set up the database to work in single-user mode.
Setup method: Right-click on the database you want to restore, select Properties on the right-click menu command > Options-> Status-> Restrict Access-> "single"

SQL Server Backup restores database times usage errors

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.