Advertisement
tei219

dbcc_showcontig

Jan 18th, 2012
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.17 KB | None | 0 0
  1. create table #dbcc_showcontig (
  2.         ObjectName      sysname,
  3.         ObjectId        int,
  4.         IndexName       sysname,
  5.         IndexId         smallint,
  6.         Level           smallint,
  7.         Pages           int,
  8.         Rows            int,
  9.         MinimumRecordSize       int,
  10.         MaximumRecordSize       int,
  11.         AverageRecordSize       float,
  12.         ForwardedRecords        int,
  13.         Extents int,
  14.         ExtentSwitches  int,
  15.         AverageFreeBytes        float,
  16.         AveragePageDensity      float,
  17.         ScanDensity     float,
  18.         BestCount       int,
  19.         ActualCount     int,
  20.         LogicalFragmentation    int,
  21.         ExtentFragmentation     int
  22. )
  23.  
  24. select * into #showcontig_summary from #dbcc_showcontig
  25. alter table #showcontig_summary add dbname sysname
  26.  
  27. exec sp_MSforeachdb @command1 = '
  28.     print ''?''
  29.     use ?
  30.     insert into #dbcc_showcontig exec(''dbcc showcontig with tableresults, all_indexes'')
  31.     insert into #showcontig_summary select *, db_name() as dbname from #dbcc_showcontig
  32.     truncate table #dbcc_showcontig
  33. '
  34.  
  35. select * from #showcontig_summary
  36.  
  37. drop table #dbcc_showcontig
  38. drop table #showcontig_summary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement