use UFDATA_036_2018 DECLARE @TbName VARCHAR(80) DECLARE FindErrTable SCROLL CURSOR FOR select name from UFDATA_036_2018.dbo.sysobjects where xtype=''u'' order by name OPEN FindErrTable FETCH FindErrTable INTO @TbName WHILE @@FETCH_STATUS<>-1 BEGIN print @TbName exec( ''select top 1 * from '' + @TbName) FETCH FindErrTable INTO @TbName END PRINT ''Scan Complate扫描完成…'' CLOSE FindErrTable DEALLOCATE FindErrTable
以上为查错表
——————————————————————————
USE UFDATA_036_2018 DECLARE @TableName varchar(255) DECLARE TableCursor CURSOR FOR
SELECT Table_Schema+''.''+Table_Name FROM information_schema.tables WHERE table_type = ''base table''
OPEN TableCursor
FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0 BEGIN
DBCC DBREINDEX(@TableName,'' '',90)
FETCH NEXT FROM TableCursor INTO @TableName END
CLOSE TableCursor DEALLOCATE TableCursor |