Try this
-- Shows all user tables and row counts for the current database --
--===Remove OBJECTPROPERTY function call to include system objects
SELECT o.NAME, i.rowcnt FROM sysindexes AS i
INNER JOIN sysobjects AS o
ON i.id = o.id WHERE i.indid < 2 AND OBJECTPROPERTY(o.id, 'IsMSShipped') = 0
ORDER BY o.NAME
The above is NOT my code, but rather an article written many years ago here on SSC by an author whose name I have forgotten - may he/she pardon me for not quoting them to give the credit deserved
You could run the above query to place the results into a local temporary table and then update your permanent table using a join to the temp table.
Here is another video to demonstrate the sp_foreachtable
http://qa.sqlservercentral.com/articles/Video/66317/
by Andy Warren
sp_msforeachtable 'SELECT ''?'', COUNT(*) FROM ?'
If everything seems to be going well, you have obviously overlooked something.
Ron
Please help us, help you -before posting a question please read[/url]
Before posting a performance problem please read[/url]