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.