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

  • happycat - you would need to move your additional criteria into the join.

    [font="Courier New"]SELECT

    SO.Name

    , SI.RowCnt

    FROM

    SysObjects SO

    INNER JOIN SysIndexes SI ON SO.ID = SI.ID and SI.IndID IN (0, 1)

    WHERE

    SO.Type = 'u'

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

    The NULL condition is to handle tables with no indexes. I wanted to make sure the query did not ignore heaps, so it returns rows with no sysindexes entries.