Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to attach database after mistakenly deleting SQLServer log file

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to attach a database after deleting SQL Server log files by mistake". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to attach a database after deleting SQL Server log files by mistake"!

The solution is as follows:

Create a database with the same name.

2. Stop the database service and overwrite the newly created database master file (tip: it is best to put it on the same disk, delete or remove the newly created database master file, and then cut the database master file to be restored, so as to save time.)

Start the database service, and the database becomes suspicious or suspicious. Then run in Query Analyzer:

alterdatabase The name of the database without log files.

Set emergency to emergency.

How to attach database after deleting SQL Server log file by mistake

4. Re-run:

alterdatabase name of database without log file setsingle_user

Or:

Sp_dboption'database name without logfile',' singleuser','true'

Set to single user mode.

5. Check and rebuild log files, run:

dbcccheckdb ('database name without logfile', REPAIR_ALLOW_DATA_LOSS)

this time is relatively long. Patience! If there is an error, run:

dbcccheckdb ('database name without logfile', REPAIR_REBUILD)

to repair it. If there are no mistakes, you can skip it.

6. Restore to multi-user mode

alterdatabase name of database without log file setmulti_user

Or:

Sp_dboption'database name with no log file',' singleuser','false'

Refresh the database, you can see the database has been repaired, this time you can successfully attach the database.

Thank you for reading, the above is "how to attach database after deleting SQL Server log file by mistake" content, after learning this article, I believe that we have a deeper understanding of how to attach database after deleting SQL Server log file by mistake, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report