by
0
6
2,341
2
Top 1% !
Popular
Famous
Tagged
Specified
OpenSource
Popularity: 7362nd place
Architecturex86_64
DBMSMS SQL Server
LanguageT-SQL
LicenseMIT_X11
OSWindows

Find columns used in indexes for SQL Server

Retrieves a number of information related to the structure of the available indexes
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/206182/Find-columns-used-in-indexes-for-SQL-Ser?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
SELECT TableName = t.name, IndexName = ind.name, ColumnName = col.name, FGName = f.name, ic.is_descending_key, ic.is_included_column, ind.is_unique, ind.type_desc, ic.* FROM sys.indexes ind INNER JOIN sys.index_columns ic ON ind.object_id = ic.object_id and ind.index_id = ic.index_id INNER JOIN sys.columns col ON ic.object_id = col.object_id and ic.column_id = col.column_id INNER JOIN sys.tables t ON ind.object_id = t.object_id INNER JOIN sys.[filegroups] f ON f.[data_space_id] = ind.data_space_id WHERE ind.is_unique_constraint = 0 AND t.is_ms_shipped = 0 ORDER BY t.name, ind.name, ind.index_id, ic.index_column_id
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus