Seznam include sloupců v indexu

DECLARE @TableNameWithSchema sysname = ‚lovs.Table‘
DECLARE @IndexName sysname = ‚ix_IndexName‘
SELECT
sc.name
— COUNT(sc.name) AS IncludeColumnNameCnt
FROM
sys.indexes i
JOIN
sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
JOIN
sys.columns sc ON ic.object_id = sc.object_id AND ic.column_id = sc.column_id
WHERE
i.object_id = OBJECT_ID(@TableNameWithSchema)
AND i.name = @IndexName
AND ic.is_included_column = 1