-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- DISCLAIMER - Execute at your own risk. Read this script and thoroughly test first!!! -- -- Written by Kimberly L. Tripp of SYSolutions, Inc. -- For more code samples go to http://www.sqlskills.com -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --USE dbname go CREATE TABLE #ShowContigOutput ( ObjectName sysname, ObjectId int, IndexName sysname, IndexId tinyint, Level tinyint, Pages int, Rows bigint, MinimumRecordSize smallint, MaximumRecordSize smallint, AverageRecordSize smallint, ForwardedRecords bigint, Extents int, ExtentSwitches numeric(10,2), AverageFreeBytes numeric(10,2), AveragePageDensity numeric(10,2), ScanDensity numeric(10,2), BestCount int, ActualCount int, LogicalFragmentation numeric(10,2), ExtentFragmentation numeric(10,2) ) go INSERT #ShowContigOutput EXEC ('DBCC SHOWCONTIG WITH TABLERESULTS') go SELECT ScanDensity FROM #ShowContigOutput WHERE ObjectName = 'member' AND IndexName = 'member_ident' go -- Another option would be to create a procedure and tweak it to what you want -- for a more exact and/or flexible choice for gathering densities. CREATE PROCEDURE sp_DBCCSHOWCONTIG AS DBCC SHOWCONTIG WITH TABLERESULTS go INSERT #ShowContigOutput EXEC sp_DBCCSHOWCONTIG go