I don't have a database right away to check this out, but you should see if a column exists in the index using the following IF EXISTS statement.
I'm not sure if you can change the index on the fly.
IF EXISTS
(
SELECT MyIndex.Name AS IndexName,
Columns.name AS ColumnName
FROM sys.indexes MyIndex
INNER JOIN sys.index_columns IndexColumns
ON MyIndex.index_id = IndexColumns.index_id
AND MyIndex.object_id = IndexColumns.object_id
INNER JOIN sys.columns Columns
ON Columns.column_id = IndexColumns.column_id
AND IndexColumns.object_id = Columns.object_id
WHERE Columns.name = 'ColumnName'
AND MyIndex.Name='IX_MyIndexName'
)
source
share