Sunday, April 18, 2010

Count each objects in the database

select case xtype
when 'U' then 'User Tables'
when 's' then 'System Tables'
when 'v' then 'Views'
when 'TR' then 'Triggers'
when 'p' then 'Stored procedures'
when 'pk' then 'Primary Keys'
when 'x' then 'Extended stored procedures'
when 'uq' then 'UNIQUE constraints'
when 'tf' then 'Table functions'
when 'if' then 'In-lined Table Functions'
when 'fn' then 'Scalar Functions '
when 'c' then 'CHECK Constraints'
when 'd' then 'Default'
when 'f' then 'FOREIGN KEY constraint'
when 'sq' then 'Service Broker Queues'
else 'Others' end as "OBJECT TYPE", count(*) as "OBJECT COUNT"
from sysobjects group by xtype

No comments: