SQL Server Lookup Table issues

Source: Internet
Author: User

Use the following SQL traversal table to query for problems

DECLARE @table_name VARCHAR( -)DECLARECursor_tableCURSOR  for  SELECTname fromsys.tablesOPENcursor_tableFETCH Next  fromCursor_table into @table_name while(@ @FETCH_STATUS = 0 )  BEGIN      DBCCCheckTable (@table_name)      PRINT '                                             '      PRINT '============================================='      PRINT '                                             '      FETCH Next  fromCursor_table into @table_name  ENDCLOSEcursor_tabledeallocateCursor_table

If there is a problem, a record similar to the following is entered:

Rece_money'sDBCCresults. Message8952Level -State1The1Row Table error: Table'Rece_money'(ID507148852)。 Index'Pk_rece_money'(ID -) does not match any data rows in the index row. may be redundant or invalid keys on the downside: message8956Level -State1The1Line
... ... ... Table error: Table'Rece_money'(ID507148852)。 Index'Pk_rece_money'(ID -) does not match any data rows in the index row. may be redundant or invalid keys on the downside: message8956Level -State1The1row index Row (1:171607: +) has a value of (rece_money_id= '0000148773' andRece_money_type= 'Return Payment Form' andHEAP RID=(1:34467: the)), point to by (HEAP RID=(1:34467: the) ) identifies the data row. Object'Rece_money'Of3043Page that has57111line. CheckTable in the table'Rece_money'(Object ID507148852) found in0Allocation Errors and +a consistency error. For theDBCCchecktable (Zyhadm.dbo.rece_money) found an error, Repair_rebuild is the lowest repair level. DBCCExecution is complete. IfDBCCThe error message is output, please contact your system administrator.

Fix by statement

DBCC CheckTable (Rece_money,repair_rebuild)

Related Article

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.