Row count via sysindexes

  • Hi all

    Ive seen a few scripts come through over the years that do rowcounts over the sysobjects and sysindexes tables. I have personally found this is be one of the most unreliable methods, esp if you were planning to use it for after data mig comparisons (for example). Under ss2k sp2 ive tried reindexing, re-collecting stats and STILL found discrepencies. Here is a classic piece of code:

    set @CMD = 'SELECT ' + char(39) + @DB + char(39) + 'as DB, rows, b.name FROM ' + @DB + '..sysindexes a , ' + @DB + '..sysobjects b ' +

    'WHERE a.id = b.id and type=''u'' AND indid < 2 order by b.name'

    exec (@CMD)

    Im not sure how many oters have come accross this one, but be wary at all times.

    Cheers

    Chris


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • Yes this has long been an issue in SQL 7 and had not yet checked in 2000 but I figured something was up. Personally I aim for COUNT from actual select statement.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 1 (of 1 total)

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