title: Generate CREATE INDEX statements in SQL Server
body: <p>Does anyone have a script to list of CREATE INDEX statements for all existing indexes in a SQL Server database?</p>
  
  <p>This thread <a href="https://stackoverflow.com/questions/765867/list-of-all-index-index-columns-in-sql-server-db">List of all index &amp; index columns in SQL Server DB</a> has great tips on how to find them. But a script to generate the <code>CREATE INDEX</code> statements would be great. Sometimes we come into a situation without adequate data, or indexes have been added in an ad-hoc manner over time without documentation, so the create statements are missing. Like in a situation I find myself in right now.</p>
  
  <p>Thanks.</p>