Recovery after SQL Server database crash

Source: Internet
Author: User

First, you can try sp_attach_single_file_db and try to restore your data file. Although it is unlikely to be restored

If this database executes a checkpoint, it may still be successful.
If you are not lucky enough to be lucky enough to touch the lottery, the most important database is not attach as you expected. Don't be discouraged. There are other solutions.

.
We can try to re-create a log, first set the database to emergency mode, and the status of sysdatabases is 32768, which indicates data

The database is in this status.
However, the system table cannot be changed at will.

The code is as follows: Copy code
Use Master
Go
Sp_configure 'allow updates', 1
Reconfigure with override
Go
Then update sysdatabases set status = 32768 where name =''

Now, pray for the blessing of the gods and create a new log file. The chances of success are still quite large, and the system generally recognizes your new

Logs. If no error is reported, you can just breathe a sigh of relief.
Although the data is recovered, do not think that even if the task is completed, the ongoing transaction is definitely lost, and the original data may be damaged.

Bad.
Restart SQL Server and check your database.
First set to single user mode, then do

The code is as follows: Copy code
Dbcc sp_dboption '', 'single user', 'True'
Dbcc checkdb ('')

If there is no major problem, you can change the database status back. Remember to disable the system table modification option. Update sysdatabases

The code is as follows: Copy code
Set status = 28 where name = ''. Of course, your database status may not be like this. Change it to a proper value. You can also use
Sp_resetstatus
Go
Sp_configure 'allow updates', 0
Reconfigure with override
Go

Some errors may be reported during checkdb, and you may have to discard the error data.
There are several repair options for checkdb. You can use them on your own. However, you may still have to REPAIR_ALLOW_DATA_LOSS to complete all the repairs.
Chekcdb cannot complete all the repairs. We need to perform further repairs. Use dbcc checktable to check each table.
You can use sysobjects to obtain the table list. Find all the OBJECTPROPERTY values that are IsTable and check the table list.

If an error is reported, try to select the data into another table.

Related Article

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.