I am not sure if you're interested in all constraints but INFORMATION_SCHEMA.TABLE_CONSTRAINTS doesn't seem to return the DEFAULT constraints -- TABLE_CONSTRAINTS (Transact-SQL)
CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY
This query will do a simple count against the sys.objects DMV:
select COUNT(*)
from sys.objects o
where o.type_desc like '%CONSTRAINT%';
If you are interested in listing the tables, you could run something like this:
select distinct
o.object_id
, QUOTENAME(s.name) + '.' + QUOTENAME(o.name) as [object_name]
, o.type_desc
, case when dc.parent_object_id is null then 'No' else 'Yes' end as has_default_constraint
, case when cc.parent_object_id is null then 'No' else 'Yes' end as has_check_constraint
, case when fk.parent_object_id is null then 'No' else 'Yes' end as has_foreing_key
, case when kc.parent_object_id is null then 'No' else 'Yes' end as has_primary_key
from sys.objects o
inner join sys.schemas s on s.schema_id = o.schema_id
left outer join sys.default_constraints dc on dc.parent_object_id = o.object_id and dc.schema_id = o.schema_id
left outer join sys.check_constraints cc on cc.parent_object_id = o.object_id and cc.schema_id = o.schema_id
left outer join sys.foreign_keys fk on fk.parent_object_id = o.object_id and fk.schema_id = o.schema_id
left outer join sys.key_constraints kc on kc.parent_object_id = o.object_id and kc.schema_id = o.schema_id
where o.is_ms_shipped = 0
and o.type = 'U'
order by [object_name];
This one should give you the info on your indexes:
select o.name
, i.*
from sys.objects o
inner join sys.indexes i on i.object_id = o.object_id
where o.is_ms_shipped = 0
and i.object_id > 100
and i.index_id > 0
order by o.name
, i.index_id;
- Index_Id = 0 -- HEAP (won't show up)
- Index_Id = 1 -- CLUSTERED
- Index_Id > 1 -- NONCLUSTERED