Não tenho certeza se você está interessado em todas as restrições, mas o INFORMAÇÕES_SCHEMA.TABLE_CONSTRAINTS não parece retornar as restrições DEFAULT - TABLE_CONSTRAINTS (Transact-SQL)
CHEQUE, CHAVE ÚNICA, PRIMÁRIA, CHAVE ESTRANGEIRA
Esta consulta fará uma contagem simples com relação ao sys.objects DMV:
select COUNT(*)
from sys.objects o
where o.type_desc like '%CONSTRAINT%';
Se você estiver interessado em listar as tabelas, poderá executar algo como isto:
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];
Este deve fornecer as informações sobre seus índices:
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 (não será exibido)
- Index_Id = 1 - CLUSTERED
- Índice_Id> 1 - NÃO EXCLUSIVO
object_id > 100
?