Attaching a database method that does not have a log file

Source: Internet
Author: User
Tags sql error

Original: Attaching a database method without a log file

Today the client side of the execution of SQL error, after viewing the client server database disk has been exhausted, the log file reached 500GB, and later due to my error operation caused the log file (. ldf) is deleted, Later attached. mdf files are always said no log file attached unsuccessful, later after some toss finally solved, share a bit below !

Read Catalogue

    • Operation Steps
Back to top operation steps

1. Create a new database file with the same name

2. Suspension of Sqlsetver Service

3. Overwrite the original MDF file with the new database and remove the LDF file from the new database.

4. Restart the Sqlsetver service, then see the database is like this, can't open

  

5. Execute the following SQL statement

1 --1. Setting a state of emergency2 Alter DatabaseDatabase nameSetEmergency3 --2. Set to Single user mode4 Alter DatabaseDatabase nameSetSingle_user5 --3. Check and rebuild the log file6 DBCCCheckdb'Database name', Repair_allow_data_loss)7 --4.3rd Step operation if there is an error, run step 4th, no error, skip8 DBCCCheckdb'Database name', Repair_rebuild)9 --5. Revert to multi-user modeTen Alter DatabaseDatabase nameSetMulti_user

6. The log file for the library is regenerated and the entire process is completed

Back to Top

  

Previous article: How to delete a database log file

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.