SQL server 重建索引
-- 重建索引
declare @tn nvarchar(100)
DECLARE authors_cursor CURSOR FOR select name from sysobjects where type = 'u'
OPEN authors_cursor
FETCH NEXT FROM authors_cursor INTO @tn
WHILE @@FETCH_STATUS = 0
BEGIN
print '-------------------'
print '重建表索引 : ' +@tn
dbcc dbreindex(@tn)
FETCH NEXT FROM authors_cursor INTO @tn
END
CLOSE authors_cursor
DEALLOCATE authors_cursor
-- ----------------------------------------
-- 修复数据库
-- DBCC CHECKDB('置疑的数据库名' , REPAIR_ALLOW_DATA_LOSS )
-- ----------------------------------------
Go
浙公网安备 33010602011771号