{"id":5467,"date":"2016-10-24T08:51:15","date_gmt":"2016-10-24T08:51:15","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=5467"},"modified":"2017-04-20T10:59:53","modified_gmt":"2017-04-20T10:59:53","slug":"how-to-get-index-column-names-of-a-table-from-sql-server","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/sql-server\/how-to-get-index-column-names-of-a-table-from-sql-server.html","title":{"rendered":"How to get index column names of a table from SQL Server"},"content":{"rendered":"<p><code>select i.name as IndexName, co.[name] as ColumnName<br \/>\nfrom sys.indexes i<br \/>\njoin sys.objects o on i.object_id = o.object_id<br \/>\njoin sys.schemas s on s.schema_id = o.schema_id<br \/>\njoin sys.index_columns ic on ic.object_id = i.object_id<br \/>\nand ic.index_id = i.index_id<br \/>\njoin sys.columns co on co.object_id = i.object_id<br \/>\nand co.column_id = ic.column_id<br \/>\nwhere ic.is_included_column = 0<br \/>\nand s.name='my_schema_name'<br \/>\nand o.name='my_table_name'<\/code><\/p>\n<p>See also:<\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/db2\/how-to-get-index-column-names-of-a-table-from-db2.html\">How to get index column names of a table from DB2<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/mysql\/how-to-get-index-column-names-of-a-table-from-mysql.html\">How to get index column names of a table from MySQL<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/postgresql\/how-to-get-index-column-names-of-a-table-from-postgresql.html\">How to get index column names of a table from PostgreSQL<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/sqlite\/how-to-get-index-column-names-of-a-table-from-sqlite.html\">How to get index column names of a table from SQLite<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/oracle\/how-to-get-index-column-names-of-a-table-from-oracle.html\">How to get index column names of a table from Oracle<\/a><\/p>\n<p>Some SQL Server tools you can try: <a href=\"https:\/\/www.withdata.com\/sql-server\/\"> https:\/\/www.withdata.com\/sql-server\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>select i.name as IndexName, co.[name] as ColumnName from sys.indexes i join sys.objects o on i.object_id = o.object_id join sys.schemas s on s.schema_id = o.schema_id join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id join sys.columns co on co.object_id = i.object_id and co.column_id = ic.column_id where ic.is_included_column = 0 and s.name=&#8217;my_schema_name&#8217; and o.name=&#8217;my_table_name&#8217; See [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[1720,1321],"class_list":["post-5467","post","type-post","status-publish","format-standard","hentry","category-sql-server","tag-get-index-columns","tag-sql-server"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=5467"}],"version-history":[{"count":3,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5467\/revisions"}],"predecessor-version":[{"id":6441,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5467\/revisions\/6441"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=5467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=5467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=5467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}