Need guidance to prevent database corruption


have developed software using c# (.net 4.0) , sqlexpress 2008 edition. problem facing database corrupted frequently. need guidance why database corrupted , how can prevented corruption. there 3 scenarios of corruption:
  • case 1: database corrupted following error or similar: error: 9003, severity: 20, state: 9. the log scan number (180:371:2) passed log scan in database 'mydatabase' not valid. error may indicate data corruption or log file (.ldf) not match data file (.mdf). if error occurred during replication, re-create publication. otherwise, restore backup if problem results in failure during startup. this type of corruption can repaired , data recovered. in case, similar corruption occurred.
  • case 2: one of system database master or tempdb corrupted error similar above error. in case sql service stopped. need replace files of system databases. sometime sql service started , not. have re-install sqlexpress server. problem occured.
  • case 3: database corrupted following error: error: 824, severity: 24, state: 2. sql server detected logical consistency-based i/o error: incorrect checksum (expected: 0xb956dcc; actual: 0xb956d68). occurred during read of page (1:337) in database id 5 @ offset 0x000000002a2000 in file '[mdf file path]'.  additional messages in sql server error log or system event log may provide more detail. severe error condition threatens database integrity , must corrected immediately. complete full database consistency check (dbcc checkdb). error can caused many factors; more information, see sql server books online. dbcc checkdb ([mydatabase]) all_errormsgs, no_infomsgs executed d-pc\d terminated abnormally due error state 5. elapsed time: 0 hours 0 minutes 1 seconds. setting database option auto_close off database mydatabase. this type of corruption can not repaired , data not recovered. type of corruption rare.
i need guidance why these situations arise and how can these situations prevented can add preventive measures in software.

running sql backup command would not corrupt database.



SQL Server  >  SQL Server Database Engine



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........