Friday, May 20, 2016

DMV:Indexes

To check of any primary key is a NOT a clustered index


select OBJECT_SCHEMA_NAME(so.[object_id]) as schemaname ,

so.name as TableName ,

si.name as IndexName,

si.type as IndexType,

si.is_primary_key

from sys.indexes si

inner join sys.tables so on

si.[object_id] = so.[object_id]

where si.type in (0,2)

and si.is_primary_key = 1

order by so.name