An error was recently found in the system operation, with the following error message: Error message: Query a201412c20568 Document information Error---> System.Data.OleDb.OleDbException: Failed to continue with NOLOCK due to data movement Mode scan.
At first I thought that the enterprise database is a version of SQL SERVER 2005 or higher, using the following methods:
Use MASTER GO ALTER DATABASE SET Single_user GO --Allow loss of data repair DBCC CHECKDB (work_yf, Repair_allow_data_loss)GOALTERDATABASE SET
After executing the command, the discovery cannot succeed. After a look at the database used by the enterprise, found that SQL SERVER 2000. So you can only fix it in the following ways.
The first step: query by the following code, which table is wrong
DECLARE @table_namesysnameDECLARERoy_tableCURSOR forSELECTName fromsysobjectswhereXtypeinch('u','s')OPENroy_tableFETCH NEXT fromRoy_table into @table_name while @ @FETCH_STATUS = 0 BEGINDBCCCheckTable (@table_name)PRINT '--------------Data Sheet'+@table_name + 'check and finish------------------'FETCH NEXT fromRoy_table into @table_nameENDCLOSEroy_tabledeallocateRoy_table
After you perform the above naming, the following information is displayed in the Messages window: (only error messages in the following information, other normal information has been removed)
Server: Msg 8929, Level 16, State 1, line 10 Object ID 2: Error found in text ID 177078272, the owner of the text is identified by RID = (1:135:19) ID = 661577395 and indid = 3 of data records. Server: Msg 8961, Level 16, State 1, Line 10 table error: Object ID 2. The text, ntext, or image node (located on page (1:66), slot 2, text ID 177078272) and the node on page (1:284),
The reference at slot 6 does not match. The DBCC result of ' sysindexes '. The object ' sysindexes ' has 304 rows, which are located on page 14. CheckTable found 0 allocation errors and 2 conformance errors (in table ' sysindexes ', the table has an object ID of 2). Find the index or statistic of the error by the above hint information--------------Data Sheet sysindexes is completed------------------Server: Msg 8936, Level 16, State 1, Line 10 table error: Object ID 709577566, index ID 1. The links in the B-tree chain do not match. (1:2203)->next = (1:176), but (1:176)->prev = (1:2045). Server: Msg 8977, Level 16, State 1, Line 10 table error: Object ID 709577566, index ID 1. The parent node of page (1:2,203) was not encountered. The DBCC result of ' pde_list_org '. The object ' pde_list_org ' has 216 rows, which are located on page 11. CheckTable found 0 allocation errors and 2 conformance errors (in table ' pde_list_org ', the table has an object ID of 709577566). Repair_rebuild is the lowest level of repair (for errors found by DBCC checktable (Work_yf.dbo.PDE_LIST_ORG)).--------------Data Sheet pde_list_org is completed------------------Server: Msg 8978, Level 16, State 1, Line 10 table error: Object ID 725577623, index ID 1. Page (1:3,891) a reference to it is missing from the previous page (1:3,892). There may be a problem with the link to the chain. Server: Msg 8976, Level 16, State 1, Line 10 table error: Object ID 725577623, index ID 1. The page (1:3,892) was not found in the scan operation, and its parent (1:2,198) and previous page (1:3,889) pointed to the page.
Please check for previous errors. The DBCC result of ' Pde_list_org_histroy '. The object ' Pde_list_org_histroy ' has 16755 rows, which are located on page 489. CheckTable found 0 allocation errors and 2 conformance errors (in table ' Pde_list_org_histroy ', the table has an object ID of 725577623). Repair_rebuild is the lowest level of repair (for errors found by DBCC checktable (Work_yf.dbo.PDE_LIST_ORG_HISTROY)).--------------Data Sheet Pde_list_org_histroy is completed------------------The second step, the analysis, in addition to the above italics section, it should be noted that the other is very clear, is two business table error. The italicized part refers to a system table sysindexes, which requires further queries about which indexes are wrong. 1) Use the following statement to check which indexes have problems, originally_wa_sys_status_276edeb3An error is a problem.
select * sysindexes where ID = 661577395 and indid = 3 * from sysobjects = 661577395
the third step, perform the repair operation. Here's how: -The method is as follows: --1. First, stop the database server and backup the. mdf and. ldf files of the problematic database (for example: WORK_YF) to the backup directory. --2. We use the default method to establish a database for recovery use (such as WORK_YF). It can be built in SQL server enterprise manager. --3. Shut down the database server. --4. Work_yf_log.ldf Delete the log file for the database you just generated, overwriting the database data file work_yf_data.mdf that you just generated with the database MDF file you want to repair. --5. Start the database server. You will see that the status of database Work_yf is "suspect". No action can be made on this database at this time. --6. Set the database to allow direct operating system tables. This can be done in the SQL server enterprise manager Select the database server, right-click, select "Properties",
on the "Server Settings" page will " Allow direct modification of the system catalog "a check. You can also use the following statement to implement.
Use Master go exec sp_configure 'allowupdates' ,1 go reconfigurewith Override Go
--7. Set WORK_YF to Emergency Repair mode
Update set status=-32768where dbid=db_id('work_yf ')
--you can see in SQL Server Enterprise Manager that the database is in "read only \ suspect \ offline \ Emergency mode" and you can see the tables in the database.
But there are only system tables--8. Perform a real recovery operation below to rebuild the database log file
Go DBCC rebuild_log ('work_yf','D:\Program Files\Microsoft SQL Server \mssql\data\work_yf_log.ldf') Go
--During execution, if you encounter the following message:--server: Msg 5030, Level 16, State 1, Line 1--Failed to lock the database in order to perform the operation. --DBCC execution is complete. If DBCC outputs an error message, contact your system administrator. --Indicates that your other program is using the database, and if you have just used SQL Server Enterprise Manager in the F step to open the system table for the WORK_YF library,
Then quit SQL Server Enterprise Manager to do so. --the correct execution of the completion prompt should resemble the following:--warning: The log of database ' WORK_YF ' has been rebuilt. The consistency of the transaction has been lost. You should run DBCC CHECKDB to verify physical consistency.
You will have to reset the database options, and you may need to delete the extra log files. --DBCC execution is complete. If DBCC outputs an error message, contact your system administrator. --opening in SQL Server Enterprise Manager will see the database status "only for dbo use". You can now access the user tables in the database. --9 set to single user state
Goexecsp_dboption'WORK_YF','dbo Use only','false' GOexecsp_dboption'WORK_YF','Single user','true'Go Reconfigure withOverride
--10 Repair table, specifically to repair which tables, please perform DBCC CHECKTABLE (table name), self-check. I used the option "Rebuild Index and fix (Repair_rebuild)" here.
A total of three options:
--1) Quick fix repair_fast--2) rebuild index and fix repair_rebuild--3) allow loss of data repair Repair_allow_data_loss
Use WORK_YF GO DBCC checktable (pde_list_org_histroy,repair_rebuild) GO DBCC checktable (pde_list_org,repair_rebuild) GO DBCC CheckTable (Pde_head,repair_rebuild)
--Just when I was checking, I found a _wa_sys_status_276edeb3 error, which is the statistics that SQL Server automatically establishes,
So it needs to be removed and then repaired
GO DROP STATISTICS pde_head._wa_sys_status_276edeb3 GO DBCC checktable (sysindexes,repair_rebuild) GO
--11. Verifying database consistency (can be omitted)
Use Master go DBCC
Go
--general execution results are as follows: --checkdb found 0 allocation errors and 0 Conformance errors (in database ' WORK_YF ' ).  --DBCC execution completed. If   DBCC outputs an error message, contact your system administrator. --12. Set the database to the normal state
exec ' WORK_YF ' ' Single user ' ' false ' Go exec ' WORK_YF ','dbouse only','false' Go
-If there is no error, then congratulations, you can now use the restored database properly. --13. In the final step, we will restore the "allow direct modification to the system directory" setting in step e. Because the direct operating system table is a relatively dangerous thing.
Of course, we can recover from SQL Server Enterprise Manager, or we can use the following statement to complete
exec sp_configure 'allow updates',0 go Reconfigurewith override go
Fix "failed to continue scanning in NOLOCK mode" due to data movement "error database