Today a database corruption, regardless of the table query, modify, add error, error message is as follows:
I/O error (Bad page ID) detected during read at offset 0x0000000171a000 in file "path \ File"
Connection interrupted
The possibility of causing the error is:
1: The server in the normal operation of the sudden power outage, causing the database file corruption.
2: I/O error encountered while reading or writing a request to a device. This error usually indicates a disk problem.
But for the above problems are unavoidable, fortunately, the Internet found a solution (as follows)
When this problem occurs, there are 2 possible scenarios:
1: Error when attaching the database: 823
2: The database can be attached successfully, but I/O error (Bad page ID) detected during error occurred while querying and modifying a specified table.
Workaround:
The first additional database problem can be consulted: http://blog.csdn.net/shazhuyubaichi/article/details/6696031
Second question:
[SQL]View Plaincopy
- sp_dboption ' database name ', ' singleuser ', 'true '
- Go
- DBCC CHECKDB (' database name ', Repair_allow_data_loss)
- Go
- sp_dboption ' database name ', ' single user ', 'false '
- Go
I'm glad to be able to fix it with the above statement.
Here is a summary of the online, I did not test, first recorded, may be useful later.
[SQL]View Plaincopy
- Scenario 1: Call DBCC CHECKDB (' db_name ', repair_rebuild) fix
- Scenario 2: If scenario 1 fails, use the following method to try it out:
- First, create a new database in Enterprise Manager (such as the database named Test), and after the database is built, stop the SQL Server Service Manager,
- and rename the MDF file of the customer database to Test_data.mdf (that is, the primary file name of the new database).
- Then overwrite the file with the name of the new database with the renamed file.
- Next, start Enterprise Manager. Set the system table to a change state for the master database
- Use Master
- Go
- sp_configure ' allow updates ', 1
- Reconfigure with override
- Go
- Set the database to a state of emergency:
- Update sysdatabases Set status = 32768 where name = ' database '
- Stop and restart SQL Server Service Manager and rebuild the log file:
- DBCC TRACEON (3604)
- DBCC rebuild_log ( ' test ', ' test_log_ldf ')
- Set the database to single-user mode and then detect:
- sp_dboption ' test ', ' single user ', ' true '
- DBCC CHECKDB ( ' test ')
- Go
- When this database executes CHECKDB, the indexes of some tables are found to be corrupted, and the indexes are rebuilt for the specific table:
- DBCC dbreindex (table name)
- Scenario 3: If it cannot be repaired, it can only be restored in a heavy backup.
SQL Error 823 I/O error (Bad page ID) detected during read "repair method"