• Jeffrey Williams (8/10/2008)


    For SQL Server 2005 and greater - there is no need to cursor at all. Just use the DMV sys.dm_db_partition_stats as in the following:

    Select object_schema_name(object_id) As SchemaName

    ,object_name(object_id) As ObjectName

    ,row_count

    From sys.dm_db_partition_stats

    Where index_id < 2

    And object_schema_name(object_id) <> 'sys'

    Order By object_schema_name(object_id);

    Again, I ask... do you have to update usage for the rowcounts to be accurate?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)