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

  • For a quick solution, you can check the row count of the indexes on the tables rather than counting the actual rows.

    [font="Courier New"]SELECT

    SO.Name

    , SI.RowCnt

    FROM

    SysObjects SO

    LEFT JOIN SysIndexes SI ON SO.ID = SI.ID AND SI.IndID = 1

    WHERE

    SO.Type = 'u'

    AND (SI.RowCnt IS NULL OR SI.RowCnt < 100)[/font]

    This will return the tables with less than 100 rows and any tables without any indexes will have a rowcount of NULL.