title: Can I pass variable to select statement as column name in SQL Server
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5637983/sql-select-dynamic-column-name-based-on-variable">SQL: Select dynamic column name based on variable</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following simple <code>select</code> statement:</p>
  
  <pre><code> DECLARE @value varchar(10) 
   SET @value = 'intStep' 
  
   SELECT @value FROM dbo.tblBatchDetail 
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code> SELECT CAST(@value AS varchar(10)) FROM dbo.tblBatchDetail 
  </code></pre>
  
  <p>and all I get a list of <code>intstep</code> </p>
  
  <p><strong>QUESTION</strong>: can I pass variable as column name to this statement? Or what is the best way of doing this </p>
  
  <p>I'm using SQL Server 2008 (9.0 RTM) </p>
  
  <p>This will be a stored procedure </p>
  
  <p>Thanks in advance </p>