title: SQL Server Dynamic Pivot Column Names
body: <p>For the necessity of my application, I must return the column names of a query as the very first row.
  Now I must PIVOT this result in order to UNION it with my result set, but the difficult part is: it must be dynamic, so if I ever add new columns to this table, the SELECT will bring all the names pivoted.</p>
  
  <p>The following SELECT brings me the Column names:</p>
  
  <pre><code>SELECT COLUMN_NAME 
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE TABLE_NAME = 'Codes'
  ORDER BY INFORMATION_SCHEMA.COLUMNS.ORDINAL_POSITION 
  </code></pre>
  
  <p>And my result set is:</p>
  
  <pre><code>COLUMN_NAME
  Id
  CodeName
  Country
  StartDate
  EndDate 
  </code></pre>
  
  <p>What I expect is:</p>
  
  <pre><code>Id    CodeName    Country    StartDate    EndDate (... whatever other columns I might have)
  </code></pre>
  
  <p>Is there any easy way to do that without hardcoding the column names?</p>
  
  <p>Thank you in advance!</p>