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)
 getting table and stored proc

Author  Topic 

nikita
Starting Member

7 Posts

Posted - 2007-12-20 : 23:13:17
Hi,

I want to get a count of tables & user stored procedures in my database

How to do it?

thank you

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-20 : 23:17:15
[code]SELECT COUNT(*) FROM sys.tables
SELECT COUNT(*) FROM sys.procedures[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

nikita
Starting Member

7 Posts

Posted - 2007-12-20 : 23:20:46
thank you friend..

I tried SELECT COUNT(*) FROM sys.columns but it gives cumulative columns of all tables..

how can i list count of columns, indexes for all tables in a database. If a db does not have index, count should be 0

thank you
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-20 : 23:29:44
quote:
I tried SELECT COUNT(*) FROM sys.columns but it gives cumulative columns of all tables..

This will give you a count of number of columns in database. What do you want actually ?
this ?
SELECT 	obj_name = object_name(object_id), no_of_columns = COUNT(*) 
FROM sys.columns
GROUP BY object_id


quote:
how can i list count of columns, indexes for all tables in a database. If a db does not have index, count should be 0

use left join on sys.tables to sys.indexes


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -