cvcscvcs: Use of CURSOR is avoidable here (and almost everywhere else) when you bang your head against the wall long enough.
Same output format as yours:
SELECT name, sum(row_count) AS MAX_MSG_ID
FROM sys.dm_db_partition_stats WITH (NOLOCK), sysobjects WITH (NOLOCK)
WHERE xtype = 'U'
AND object_id = object_id('' + name + '')
GROUP BY name