SQL Error 823 I/O error (Bad page ID) detected during read "repair method"

Source: Internet
Author: User

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
    1. sp_dboption ' database name ', ' singleuser ', 'true '
    2. Go
    3. DBCC CHECKDB (' database name ', Repair_allow_data_loss)
    4. Go
    5. sp_dboption ' database name ', ' single user ', 'false '
    6. 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
    1. Scenario 1: Call DBCC CHECKDB (' db_name ', repair_rebuild) fix
    2. Scenario 2: If scenario 1 fails, use the following method to try it out:
    3. 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,
    4. and rename the MDF file of the customer database to Test_data.mdf (that is, the primary file name of the new database).
    5. Then overwrite the file with the name of the new database with the renamed file.
    6. Next, start Enterprise Manager. Set the system table to a change state for the master database
    7. Use Master
    8. Go
    9. sp_configure ' allow updates ', 1
    10. Reconfigure with override
    11. Go
    12. Set the database to a state of emergency:
    13. Update sysdatabases Set status = 32768 where name = ' database '
    14. Stop and restart SQL Server Service Manager and rebuild the log file:
    15. DBCC TRACEON (3604)
    16. DBCC rebuild_log ( ' test ', ' test_log_ldf ')
    17. Set the database to single-user mode and then detect:
    18. sp_dboption ' test ', ' single user ', ' true '
    19. DBCC CHECKDB ( ' test ')
    20. Go
    21. When this database executes CHECKDB, the indexes of some tables are found to be corrupted, and the indexes are rebuilt for the specific table:
    22. DBCC dbreindex (table name)
    23. 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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.