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
 General SQL Server Forums
 New to SQL Server Programming
 SQL Query to Count the number of rows and columns

Author  Topic 

pritamkusiyait
Starting Member

2 Posts

Posted - 2011-10-22 : 20:35:44
Hi,

I am trying to count the number of rows and columns of the multiple table(around 100 table) using single query can any one help to write the sql query for this.

Right now i am using Query:
SELECT count(*) as "total number of columns"
FROM sysibm.columns
WHERE TBNAME = 'REF_AUTO_CD'
AND TBCREATOR = 'DSN'

But this query returns only the number of columns for REF_AUTO_CD table is it possible to count both the rows and column for 100 tables in same query rather that using this query for all table on by one. All these 100 tables has same columns name because all these table are refrence table.

Thank You.....

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-23 : 02:08:46
are you using db2? if yes, please post in some db2 forums. this is MS SQL Server forum so people here might not be well versed in DB2.
Anyways, you can try the below as a start


SELECT TBNAME ,count(*) as "total number of columns"
FROM sysibm.columns
WHERE TBCREATOR = 'DSN'
GROUP BY TBNAME


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

pritamkusiyait
Starting Member

2 Posts

Posted - 2011-10-23 : 23:47:50
Thank You for your reply yes i am using DB2 but the above query doesn't work.....thanks once again
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-24 : 04:15:32
np

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -