-->

Find Table without Clustered Index / Primary Key

Post a Comment

One of the basic Database Rule I have is that all the table must Clustered Index. Clustered Index speeds up performance of the query ran on that table. Clustered Index are usually Primary Key but not necessarily.

SELECT OBJECT_NAME(i.OBJECT_ID) AS tableName, rows
FROM sys.indexes i
INNER JOIN sys.partitions p ON i.object_id = p.object_id AND i.index_id = p.index_id
WHERE i.INDEX_ID = 0
AND OBJECTPROPERTY(i.OBJECT_ID,'IsUserTable') = 1
ORDER BY 2 DESC 
 

Related Posts

There is no other posts in this category.

Post a Comment

Subscribe Our Newsletter