title: Generate script of all indexes, keys in the SQL Server database
body: <p>I am looking to generate scripts like:</p>
  
  <pre><code>ALTER TABLE dbo.Person 
      ADD CONSTRAINT PK_Person PRIMARY KEY CLUSTERED (PersonID);
      CREATE INDEX IX_EVT_EVENTS on EVT_EVENTS(prg_event_t1, prg_event_t2, num_order)
  </code></pre>
  
  <p>The main problem I cannot find all information that I need, for example this query:</p>
  
  <pre><code>SELECT t.name TableName, I.* 
  FROM sys.indexes I 
  Inner Join sys.tables T on i.object_id=t.object_id
  </code></pre>
  
  <p>returns information about all keys and indexes, but.. there is no "Columns' Name" where can I get them?</p>
  
  <p>I tried sys.all_columns and sys.key_constraints also.</p>