recover database from lost or corrupted log.docx
TRANSCRIPT
-
7/28/2019 Recover Database from Lost or corrupted Log.docx
1/2
Recover Database from Lost or corrupted Log FileDecember 29, 2010msufian4 comments
Not getting much into theoretical part, you can read more about features in details from BOL or
Search it on the web, lets start with the issue and resolution.
Issue:
SQL Server shutdown unexpectedly (not clean shutdown) or Server Crashed or disk Crashed. Onrecovering the system or on starting the SQL Server services Database state changes to suspect. On
checking the error you found
Message1:|
FileMgr::StartLogFiles: Operating system error 2(The system cannot find the file specified.) occurred
while creating or opening file D:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Database_LogFile.LDF. Diagnose and correct the
operating system error, and retry the operation.
Message2:|
File activation failure. The physical file name D:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Database_LogFile.LDF may be incorrect.
Message3:|
The log cannot be rebuilt because there were open transactions/users when the database was
shutdown, no checkpoint occurred to the database, or the database was read-only. This error could
occur if the transaction log file was manually deleted or lost due to a hardware or environment failure.
Messag4:|
Backup detected log corruption in database system. Context is FirstSector. LogFile: 2 D:\Program
Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Database_LogFile.LDF VLF
SeqNo: x2572 VLFBase: x4a60000 LogBlockOffset: x4ae3200 SectorStatus: 2
LogBlock.StartLsn.SeqNo: x2043 LogBlock.StartLsn.Blk: x200000 Size: x0 PrevSize: x0
Message5:|
Msg 945, Level 14, State 2, Line 1
Database Database Name cannot be opened due to inaccessible files or insufficient memory or disk
space. See the SQL Server errorlog for details.
Resolution
In case u lost the Log file (.Ldf)(Disk corruption, file deleted or SQL Server not able access the log file
due to latency or disk issue) then the transaction which are not committed or not written to the data
pages (hardened) will be lost (Might be possibility that u may see some data consistency issue).
Check the status of the Database by querying the system tables or views
select name,state,state_desc from sys.databases where name=XYZ
Name State State_desc
Database 3 RECOVERY_PENDING
The only possible way to bring the database online is rebuilding the log file.
Set the database in Emergency Mode
ALTER DATABASE XYZ SET EMERGENCY
select name,state,state_desc from sys.databases where name=XYZ
http://sqlship.wordpress.com/2010/12/29/recover-database-from-lost-or-corrupted-log-file/http://sqlship.wordpress.com/2010/12/29/recover-database-from-lost-or-corrupted-log-file/http://sqlship.wordpress.com/author/msufian/http://sqlship.wordpress.com/author/msufian/http://sqlship.wordpress.com/author/msufian/http://sqlship.wordpress.com/author/msufian/http://sqlship.wordpress.com/author/msufian/http://sqlship.wordpress.com/2010/12/29/recover-database-from-lost-or-corrupted-log-file/ -
7/28/2019 Recover Database from Lost or corrupted Log.docx
2/2