Sunday, September 4, 2011

Object counts in SQL server Database

select
case xtype
when 'D' then 'Default Constraint'
when 'F' then 'Foreign Key Constraint'
when 'FN' then 'Function(s)'
when 'P' then 'Stored Procedure'
when 'PK' then 'Primary Key Constraint'
when 'SQ' then 'SQ'
when 'U' then 'User defined table'
when 'UQ' then 'Unique Constraint'
Else 'Other'
end Object_nm,
count(1) cnt
from dbo.sysobjects
where UID=1
group by xtype order by cnt desc

No comments: