Monday, 14 May 2012

* Simple select query to find the total index count in a database breakdown by type

As we all already know that index consideration in SQL Server mainly revolves around 2 types... Clustered and Non-clustered.
         The below query helps you to find out the actual index count in your database whether it is Clustered or Non-clustered.

It also provides you the count of tables without any indexes(Heaps)....

SELECT i.type_desc, count(*) as cnt FROM sys.indexes i  INNER JOIN sys.objects o  ON i.object_id = o.object_id  WHERE o.type<>'S' GROUP BY i.type_desc