COunt difference

  • 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

  • the counts are probably out of date, try running ;

    DBCC UPDATEUSAGE

  • Sorry. Missed the second column in the first query.

  • select row_count from sys.dm_db_partition_stats

    where object_id = (object_id('abcd'))

    try this , it was asked a q Qotd and works faster

    Jayanth Kurup[/url]

  • Jayanth_Kurup (6/22/2011)


    select row_count from sys.dm_db_partition_stats

    where object_id = (object_id('abcd'))

    try this , it was asked a q Qotd and works faster

    its worth noting that this method can still be inaccurate, as the only fully accurate way is count(*)

  • I was under the assumption that dm_db_partition_stats was accurate , i tried to create a few scenarios where is tot it would be inaccurate but didn't face any problems.

    Here's an article I found on the topic.

    http://www.sqlservercentral.com/articles/T-SQL/67624/

    Jayanth Kurup[/url]

  • Jayanth_Kurup (6/22/2011)


    I was under the assumption that dm_db_partition_stats was accurate , i tried to create a few scenarios where is tot it would be inaccurate but didn't face any problems.

    Here's an article I found on the topic.

    http://www.sqlservercentral.com/articles/T-SQL/67624/%5B/quote%5D

    thanks for the link , I was under the assumption that it could be inaccurate but it appears not..

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply