SQL Server: Displaying Index Table by Query

In addition using the object explorer, we can display the index data that exist on a particular table by the following query:
SELECT
     TableName = t.name,
     IndexName = i.name,
     IndexId = i.index_id,
     ColumnId = ic.index_column_id,
     ColumnName = c.name
FROM
     sys.indexes i
INNER JOIN
     sys.index_columns ic ON  i.object_id = ic.
object_id and i.index_id = ic.index_id
INNER JOIN
     sys.columns c ON ic.
object_id = c.object_id and ic.column_id = c.column_id
INNER JOIN
     sys.tables t ON i.
object_id = t.object_id
WHERE
     t.name = 'NAMATABEL'


Click here if you like this article.


Post a Comment

0 Comments