SQL Server ldf lost database recovery

Source: Internet
Author: User
Tags sql server management

If the ldf file of the database is lost or damaged, the Database loading fails. Check SQL Server Management> SQL Server Logs to see that ldf loading fails.

 

1. view the database status

Select * from sys. databases

The state_desc of the corresponding database is Recovery.

You can view the database status at any time in subsequent steps

 

2. Allow database updates

Sp_configure 'Allow updates', 1

Go

Reconfigure with override

GO

It seems that this step is not done. You can also use it.

 

3. Take the database offline

Alter database Test set offline

Go

4. Set the database to an emergency

Alter database Test set emergency

Go

 

5. Set the single-user mode

Alter database Test set single_User

Go

6. Use DBCC to restore logs

DBCC checkdb ('test', REPAIR_ALLOW_DATA_LOSS) with NO_INFOMSGS

Dbcc checkdb ('test', REPAIR_REBUILD)

7. This step should be okay. The following is how to restore the database to a normal state.

Exec sp_resetstatus 'test'

Exec sp_dboption 'test', n' single ', 'false'

Alter database Test set online

Go

 

8. Disable update.

Sp_configure 'Allow updates', 0

Go

Reconfigure with override

GO

 

The database has been restored.

 

 

 

 

 

 

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.