hHow to get table schema with there indexes in sql server.?????
Thanks in advance
How to get table schema with there indexes
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Sep 15, 2013, 10:06 PM EDT
i think, there is no deirect way to find table schema and indexes together.
sp_help and sp_helpIndex may help you.
please refer
http://www.razorsql.com/articles/ms_sql_server_admin_queries.html
hope this will help you.
Jeetendra GundRank #97 · 22.1K reputationPosted Sep 16, 2013, 12:01 AM EDT
SELECT ind.name ,ind.index_id ,ic.index_column_id ,col.name ,ind.* ,ic.* ,col.* 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 WHERE (1=1) AND ind.is_primary_key = 0 AND ind.is_unique = 0 AND ind.is_unique_constraint = 0 AND t.is_ms_shipped = 0 ORDER BY t.name, ind.name, ind.index_id, ic.index_column_id try this link, hope so http://stackoverflow.com/questions/765867/list-of-all-index-index-columns-in-sql-server-db