original post: Row Count Using sysindexes System Table
Another alternative way to count the number of rows in the database tables is to make use of sysindexes system table. indid = 1 in this table means clustered index. In case the table does not have a clustered index, we are still able to count its rows, using indid = 0. It goes like so:
SELECT O.[name]
,I.rowcnt
FROM sysobjects O
JOIN sysindexes I
ON O.[id] = I.[id]
WHERE O.xtype = 'U'
AND O.status > 0
AND I.indid = 1
No comments:
Post a Comment