Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 5123

Need guidance to prevent database corruption

$
0
0
I have developed a software using C# (.Net 4.0) and SQLExpress 2008 Edition. The problem I am facing is that the database is corrupted too frequently. I need guidance why the database is corrupted and How it can be prevented from corruption. There are three scenarios of corruption:
  • Case 1: Database is corrupted with following error or similar: Error: 9003, Severity: 20, State: 9. The log scan number (180:371:2) passed to log scan in database 'MyDatabase' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup. This type of corruption can be repaired and data is recovered. In most case, the similar corruption occurred.
  • Case 2: One of the system database like master or tempdb is corrupted with error similar to above error. In this case the sql service is stopped. I need to replace the files of system databases. Sometime the sql service is started and sometimes it do not. Then I have to re-install the SQLExpress server. This problem is rarely occured.
  • Case 3: Database is corrupted with following error: Error: 824, Severity: 24, State: 2. SQL Server detected a logical consistency-based I/O error: incorrect checksum (expected: 0xb956dcc; actual: 0xb956d68). It occurred during a read of page (1:337) in database ID 5 at offset 0x000000002a2000 in file '[MDF File Path]'.  Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe 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. DBCC CHECKDB ([MyDatabase]) WITH all_errormsgs, no_infomsgs executed by d-PC\d terminated abnormally due to error state 5. Elapsed time: 0 hours 0 minutes 1 seconds. Setting database option AUTO_CLOSE to OFF for database MyDatabase. This type of corruption can not be repaired and data is not recovered. This type of corruption is most rare.
I need guidance why these situations arise and how can these situations be prevented so that I can add preventive measures in software.

Viewing all articles
Browse latest Browse all 5123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>