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 2000 Forums
 SQL Server Development (2000)
 Getting the number of rows in each table for all tables in a database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-22 : 10:05:09
Julian writes "I would like to write a stored procedure that will return a recordset with the table name in one column and the total number of rows in each table in the other column.

My Attempt:

I first created a temporary table and then copied all the user table names from the sysObject table into the first column. Then, using a cursor, I try to step through the temporary table, assigning the current table name to a variable.

I then tried to use the variable in a

select count(*)
from [variable table name]

but it didn't like that.

Now I know there is a new data type in SQL Server 2000 called table which holds the results of a query. However, I have to run this query in Sql Server 6.5. However, if you want to supply an answer for both. I would appreciate it.

Thanks for your help."
   

- Advertisement -