Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Retrieve Number of Rows For 1 Table

Author  Topic 

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2010-08-17 : 18:01:20
hi all,

My question is for 2005.

I have a table that contains information about some tables: table name, number of rows, and index name etc.

Now I need to update the "number of rows" value.

EXEC sp_spaceused @name;

sp_spaceused returns the number of records along with some other columns.

**How can I use sp_spaceused to return a value for rows which I can store into a variable for use in updating my table? **

This needs to be dynamic so I can loop thru several table names, retrieivng the rows for each table...

Thanks, John

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-08-17 : 18:33:35
Try this:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53843

You can modify the code to meet your needs...it's a modified version of sp_spaceused.
Go to Top of Page
   

- Advertisement -