Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Created February 26, 2019 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpoDesign/8f36fbcce728dfbcb8e1edfbf313ce99 to your computer and use it in GitHub Desktop.
Save cpoDesign/8f36fbcce728dfbcb8e1edfbf313ce99 to your computer and use it in GitHub Desktop.
Find an index with a specific name
select * from sys.tables as t
inner join sys.columns as c
on t.object_id = c.object_id
inner join sys.index_columns as ic
on c.column_id = ic.column_id and c.object_id = ic.object_id
inner join sys.indexes as i
on ic.index_id = i.index_id and ic.object_id = i.object_id
WHERE t.name = 'table_name' AND i.name = 'index_name'
-- where t.name = 'table_name' and c.name = 'column_name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment