[MSSQL] 查詢Index資料
SELECT obj.name TableName, ind.name IndexName, col.name IndexColumn, incol.index_column_id IndexColumnSN
FROM sys.columns col
INNER JOIN sys.objects obj ON obj.object_id = col.object_id
INNER JOIN sys.index_columns incol ON incol.COLUMN_ID = col.column_id AND incol.object_id = obj.object_id
INNER JOIN sys.indexes ind on ind.index_id = incol.index_id AND obj.object_id = ind.object_id
WHERE obj.name = 'TableName'
order by ind.name, incol.index_column_id
留言
張貼留言