Showing posts with label Line 1. Show all posts
Showing posts with label Line 1. Show all posts

Wednesday, December 26, 2012

How to Fix DBCC CHECKDB Error: Msg 5030, Level 16, State 12, Line 1


Have you ever received such error messages after running following DBCC commands


  • DBCC CHECKDB
  • DBCC CHECKTABLE
  • DBCC CHECKALLOC
  • DBCC CHECKCATALOG
  • DBCC CHECKFILEGROUP


The full error message description is:


“ Msg 5030, Level 16, State 12, Line 1 The database could not be exclusively locked to perform the operation. 
Msg 7926, Level 16, State 1, Line 1 
Check statement aborted. The database could not be checked as a database snapshot could not be created and the database or table could not be locked. See Books Online for details of when this behavior is expected and what workarounds exist. Also see previous errors for more details. “


In this case, DBCC CHECKDB command gets failed & show above error message. There are many reasons behind this error message. Some are: 


Causes behind this error:


  • When you run the DBCC CHECKDB command on the database, at that time another connection is using the same database.  
  • If the SQL Server database has file group that is marked as read-only, this error can occur. The reason behind it is that when DBCC CHECK check database consistency then it create and use an internal database snapshot. In this case, If a read-only file group exists then the internal database snapshot is not created & this error occur.


Solution to resolve this issue: 



1.First you should create a database snapshot for the database on which you want to perform the checks. 
2.After that run the DBCC CHECK command against the database snapshot.
3.Drop the database snapshot after the DBCC CHECK command is completed.


If it does not fix your problem, but after using above steps at least DBCC CHECKDB will finish and you'll have a better idea where the real problem exist.
»»  Read More...

Thursday, October 18, 2012

How to resolve SQL server database & table corruption


I came across a situation when I was Fetching record from a table, suddenly got below error message for few records: 

Error:- Msg 823, Level 24, State 2, Line 1
The operating system returned error 23(Data error (cyclic redundancy check).) to SQL Server during a read at offset 0x000000344c000 in file 'D:\DB_NAME\DB_NAME.mdf'. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

After that I execute DBCC CHECKTABLE ("TABLE_NAME") command on the database & got below error message: 

Msg 8966, Level 16, State 2, Line 1
Unable to read and latch page (1:117) with latch type SH. 23(Data error (cyclic redundancy check).) failed. 
CHECKTABLE found 0 allocation errors and 1 consistency errors not associated with any single object.
DBCC results for 'TABLE_NAME'.
Msg 2533, Level 16, State 1, Line 1
Table error: page (1:117) allocated to object ID 1606, index ID 0, partition ID 7205, alloc unit ID 72057 (type In-row data) was not seen. The page may be invalid or may have an incorrect alloc unit ID in its header.
There are 932 rows in 927 pages for object "TABLE_NAME".
CHECKTABLE found 0 allocation errors and 1 consistency errors in table 'TABLE_NAME' (object ID 1606).
repair_allow_data_loss is the minimum repair level for the errors found by DBCC CHECKTABLE (DB_NAME.dbo.TABLE_NAME).
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

Cause: This error message occurs when database mdf file or database table get corrupted

Suggestion: If you want to find the exact cause of the error then you should run the following command before using any repair option: 

DBCC ChecKDB('<database name>') WITH NO_INFOMSGS, ALL_ERRORMSGS

Most Possible Solutions:


  • Restore your database from updated backup. 
  • If you don't have backup then you should use repair command. If you are the database administrators then you should set the database in single user mode and try DBCC CHECKDB by repair_allow_data_loss option. 
  • Repair command may repair your database or give another error message. It means this error is not repairable by repair command. In this case, you should use Third Party MS SQL Database Recovery Software. These software repairs corrupt database, database files & all database objects including table, triggers, views etc. 


Hope the article will help your to resolve  SQL Server Error "Msg 823, Level 24, State 2, Line 1". 
»»  Read More...