DECLARE @v_Num INT DECLARE @v_SQL VARCHAR(1000) DECLARE @v_TableName VARCHAR(1000) DECLARE @v_OwnerName VARCHAR(1000) SET @v_Num = 1 DECLARE DB_Cursor CURSOR FOR SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_SCHEMA, TABLE_NAME OPEN DB_Cursor FETCH NEXT FROM DB_Cursor INTO @v_OwnerName, @v_TableName WHILE @@FETCH_STATUS = 0 BEGIN SET @v_SQL = 'ALTER INDEX ALL ON ' + @v_OwnerName + '.' + @v_TableName + ' REBUILD WITH (PAD_INDEX = ON, FILLFACTOR = 90) ' EXEC(@v_SQL)
PRINT CONVERT(VARCHAR(16), @v_Num) + '__' + @v_OwnerName + '.' + @v_TableName + '............ OK'
SET @v_Num = @v_Num + 1 FETCH NEXT FROM DB_Cursor INTO @v_OwnerName, @v_TableName END CLOSE DB_Cursor DEALLOCATE DB_Cursor |
카테고리 없음
mssql index rebuild
728x90
댓글