June 21, 2011 at 7:18 am
Hi
For me count 207 rows when i use
SELECT
sysobjects.Name
, sysindexes.Rows
FROM
sysobjects
INNER JOIN sysindexes
ON sysobjects.id = sysindexes.id
WHERE
type = 'U'
AND sysindexes.IndId < 2
ORDER BY
sysobjects.Namecode
to get count of rows
and when i make "select count(*) from tableName" show me 209 rows why (This happen only in case of 3 tables) Why?
Can some one help me out with this please
June 21, 2011 at 8:12 am
I personally like using the INFORMATION_SCHEMA.TABLES view.
June 21, 2011 at 8:20 am
None of the system table are 100% accurate 100% of the time.
if you need an absolute exact count then you need to do count(*). But then again that number can be changing 1 000 000 times / day so you need to define what & when the count really means something.
Here's something that's a little more precise than dbo.sysindexes.
SELECT
OBJECT_NAME(p.object_id) AS ObjectName
, p.object_id
, SUM(p.rows) AS rows
FROM
sys.partitions p
WHERE
p.index_id IN ( 0 , 1 )
GROUP BY
p.object_id
HAVING
SUM(rows) > 0
ORDER BY
rows DESC
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply