• Hello,

    The script is fine but using MS_foreach is undocumented ! :hehe:

    I prefer to use:

    SELECT table_name,table_rows FROM (

    select so.name as table_name, si.rowcnt as table_rows,ROW_NUMBER() OVER (PARTITION BY SO.NAME ORDER BY si.rowcnt DESC) AS RC

    from sysobjects so

    join sysindexes si on so.id = si.id and so.type = 'U'

    )F WHERE RC = 1

    ORDER BY table_name

    HTH,

    \\K

    ______________________________________________________________________________________________________________________________________________________________________________________
    HTH !
    Kin
    MCTS : 2005, 2008
    Active SQL Server Community Contributor 🙂