Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need sql script to show object counts

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
I need a scripts/procedure that will show the following ;
Alias ; 0
Table ; 10
Index ; 4
Constraint ; 9
etc for ALL the object types.
(Selecting from sysobjects does not give all the info)
 
You can use the sql query below and instead of else you can add when conditions to get your count for the rest of object types.


SELECT CASE
WHEN type = 'P' Then 'Procedures'
WHEN type = 'U' Then 'User Tables'
WHEN type = 'S' Then 'System Tables'
WHEN type = 'V' Then 'Views'
WHEN type = 'TR' Then 'Triggers'
WHEN type = 'XP' Then 'Extended Stored Procedures'
WHEN type = 'RI' Then 'Refrential Constraint'
ELSE 'Others'
END
AS Objects,
COUNT(type) AS Occurs
FROM sysobjects GROUP BY type


Hope this answered your question.

Murali
[2thumbsup]
 
N,,,this does not give me the other objects like indexes,group,etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top