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.