Restore of a single MDF file

Source: Internet
Author: User
Tags microsoft sql server mssql create database

A Project Project platform (PWA) outage occurs unexpectedly and the configuration database Sharepoint_config ldf is accidentally deleted and cannot be attached if the MDF file is attached directly.
Try sp_attach_single_file_db recovery first, and do the following:
sp_attach_single_file_db ' Sharepoint_config ', ' D:/program files/microsoft SQL server/mssql.1/mssql/data/sharepoint_ Config.mdf '
An error message appears:
File activation failed. Physical file name ' D:/program files/microsoft SQL server/mssql.1/mssql/data/sharepoint_config_log. LDF ' may not be correct.
The log could not be rebuilt because the database was not completely shut down.
Message 1813, Level 16, State 2, line 1th
Unable to open new database ' Sharepoint_config '. CREATE DATABASE aborted.
Then try the following steps:
1. New Sharepoint_config Database
2. Stop SQL SERVER 2005, overwrite the original sharepoint_config. mdf database file with the newly created sharepoint_config. mdf database file, restart the database,
The tables in the database are not read correctly at this time.
3. Set the database to a state of emergency:
ALTER DATABASE sharepoint_config SET emergency
When the data is in a critical state, the tables in the library can read
4. Execute the following code:
Use master
DECLARE @databasename varchar (255)
Set @databasename = ' Sharepoint_config '--set variable to data name
exec sp_dboption @databasename, n ' single ', n ' true '--set database to Single-user state
DBCC CHECKDB (@databasename, Repair_allow_data_loss)
DBCC CHECKDB (@databasename, Repair_rebuild)
exec sp_dboption @databasename, n ' single ', n ' false '--set target data base to multiuser state
The database is normal.

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.