MUST Corp.
Compare Page Revisions
« Older Revision - Back to Page History - Newer Revision »
DECLARE @TableName sysname DECLARE cur_showfragmentation CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_type = 'base table' OPEN cur_showfragmentation FETCH NEXT FROM cur_showfragmentation INTO @TableName WHILE @@FETCH_STATUS = 0 BEGIN SELECT 'Show fragmentation for the ' + @TableName + ' table' SET @TableName = '' + @TableName + '' DBCC SHOWCONTIG (@TableName) FETCH NEXT FROM cur_showfragmentation INTO @TableName END CLOSE cur_showfragmentation DEALLOCATE cur_showfragmentation