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
Change is inevitable... Change for the better is not.