"MSSQL" MSSQL restore single MDF file 1813 error

Source: Internet
Author: User
Tags mssql

Order:
MS SQL Server R2 additional MDF database times 1813 error with no LDF logs. Prompt database is forced to detach, no log can not be restored, and so on.

Possible causes:
Because the system is performing a timed job, there is no primary to multiple forced separation of the database. When attaching back MDF file times error 1813. In short, the hands of the cheap trouble ...



Workaround:
1, first to backup good MDF file, if he did not have the manager to eat you must not. They don't spit on the bones.
2. Create a new database in the database with the same name appended to it. such as "TestDB"
3. Stop the SQL Server service
4. Locate the folder where the database resides, and delete the Testdb_log.ldf and testdb.mdf files
5. Copy the database "Testdb.mdf" files that need to be attached to the current path.
6. Start the SQL Server service and connect to the database through Enterprise Manager.
7. The new database address in step 1 of this time is already pointing to the MDF file where you need to attach the database. But now the database is still not open.
8. Execute statement: ALTER DATABASE testdb SET EMERGENCY
9. Execute statement: ALTER DATABASE testdb SET single_user
10. Execute statement: ALTER DATABASE testdb REBUILD LOG on (name=dbname_log, filename= ' C:\XXX\dbname_log.ldf ')
where filename is the LDF file name you need to create a new LDF log path. After running, a warning "warning message after execution" warning: The log of database ' Xhtyjbbs ' has been regenerated. The consistency of the transaction has been lost. The RESTORE chain is broken and the server no longer has the context of the previous log files, so you need to know what they are. You should run DBCC CHECKDB to verify physical consistency. The database has been placed in dbo-only mode. When you are ready to make the database available, you need to reset the database options and remove any extra log files. "Don't bird him."

11, DBCC CHECKDB (TestDB, Repair_allow_data_loss) This step will compare cards, may cause the interface is not responding. Wait a little while. After the successful database becomes single user mode, the following two steps are modified into multi-user mode.
12. ALTER DATABASE TestDB SET multi_user
13. ALTER DATABASE TestDB SET ONLINE

Tail:
The database should be ready for use without an accident. Be sure to back up the MDF file first, even if you have a bad play and a backup.

"MSSQL" MSSQL restore single MDF file 1813 error

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.