title: SQL Server: How to set column alias from another table during select?
body: <p>I have 2 tables</p>
  
  <p>Table 1:</p>
  
  <pre><code>DB1, DB2, DB3, DB4, DB5, Some other identifiers
  </code></pre>
  
  <p>Table 2:</p>
  
  <pre><code>EnumText, EnumValue, Some other identifiers
  </code></pre>
  
  <p>What I want to do is to:-  </p>
  
  <ol>
  <li>Select data from Table 1</li>
  <li>During Select, change the alias of columns DB1 to DB5 using the Data in Table 2's EnumText column where EnumValue will contain DB1 to DB5.</li>
  </ol>
  
  <p>A sample command would be:</p>
  
  <pre><code>Select 
      DB1 as [Select EnumText from Table2 where EnumValue='DB1'], 
      DB2, DB3 
  from Table1
  </code></pre>
  
  <p>This command won't work but I hope you people got the idea.</p>
  
  <p>Thank you in advance.</p>