Home Forums SQL Server 2005 Development user tables in database where the number of rows is less than 100 RE: user tables in database where the number of rows is less than 100

  • A more accurate query is...

    SELECT

    SO.Name

    , SI.RowCnt

    FROM

    SysObjects SO

    INNER JOIN SysIndexes SI ON SO.ID = SI.ID

    WHERE

    SO.Type = 'u'

    AND (SI.RowCnt IS NULL OR SI.RowCnt < 100) -- nto 100% sure but I think rowcnt will never be null

    and SI.IndID IN (0, 1)

    A table will only have one record in SYSINDEXES with a value of either 0 or 1. This simply depends on whether (or not) the table has a clustered index.