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
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