January 31, 2013 at 9:26 am
MyDoggieJessie (1/31/2013)
Won't this work (slightly different than what's posted)? - can't say I've ever noticed a count not equaling a select COUNT on a table directlySELECT ps.row_count
FROM sys.indexes AS i
INNER JOIN sys.objects AS o ON
i.OBJECT_ID = o.OBJECT_ID
INNER JOIN sys.dm_db_partition_stats AS ps ON
i.OBJECT_ID = ps.OBJECT_ID
AND i.index_id = ps.index_id
WHERE
i.index_id < 2
AND o.is_ms_shipped = 0
AND o.object_id = OBJECT_ID(RTRIM('TableName'))
As I keep trying to say. . . it should work, but it's not guaranteed. It's an approximation.
January 31, 2013 at 9:39 am
GilaMonster (1/31/2013)
That's the rowmodctr column, not rows.Rowmodctr = row modification counter, number of rows changed since that statistic was last updated. Set to 0 when the index is rebuilt or stats updated. Replaced by the colmodctr in SQL 2005 and above.
The column 'Rows' is the total number of rows in the index.
Either way, the fact that sysindexes may not be in future versions is enough for me not to use it. 😎
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply