views:

307

answers:

1

I am doing a query

SELECT object_name(object_id, database_id) as objectname), index_id, *
FROM sys.dm_db_index_usage_stats

Is there a SQL function I can use to convert the index_id to the index name?

+1  A: 

I found a function on this page that should help you out:

CREATE FUNCTION dbo.index_name (@object_id int, @index_id int)
RETURNS sysname
AS
BEGIN
  RETURN(SELECT name FROM sys.indexes WHERE object_id = @object_id and index_id = @index_id)
END;
Espo
Or, just take this logic and add it as a join to the original query
Philip Kelley