SQL Server: Menampilkan Index Tabel

Selain menggunakan object explorer, kita dapat menampilkan data index yang ada pada sebuah tabel tertentu dengan query/sintaks berikut:

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