Restore the SQL Server database from the MDF file

Source: Internet
Author: User

1. Create a new database with the same name.

2. Set the test data offline.

3. Delete its log file test_data.ldf, do not delete the procedure behind the execution pass.

4. Log in as Superuser in Query Analyzer, execute the following stored procedure, must log in as Superuser, this is a system-level stored procedure.

exec sp_detach_db @dbname = ' test ' exec sp_attach_single_file_db @dbname = ' Test ', @physname = ' e:webdemotest_data.mdf '

5. Set the test data online.

6. Refresh the database, the table is out, the data is intact.

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.