Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Index Key Count Expand / Collapse
Posted Wednesday, September 10, 2008 12:55 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, December 9, 2010 2:28 PM
Points: 42, Visits: 79
I need to find keycnt equivalent in sysindexes table, in the new objects in SQL 2008 like sys.indexes, sys.foreign_keys.

Post #567230
Posted Wednesday, September 10, 2008 1:33 PM



Group: General Forum Members
Last Login: Saturday, December 3, 2016 5:18 AM
Points: 45,619, Visits: 44,147
Perhaps something like this will work?

SELECT object_name(i.object_id) as TableName, name as IndexName, KeyCount FROM sys.indexes i inner join
(select COUNT(*) as KeyCount, object_id, index_id from sys.index_columns where is_included_column = 0 group by object_id, index_id) ic
on i.object_id=ic.object_id and i.index_id = ic.index_id

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #567266
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse