title: Specifying Column Name As A Parameter in SELECT statement?
body: <p>I need to do something like this, but it always fails with 'Error converting data type varchar to int':</p>
  
  <pre><code>DECLARE @intParam INT
  DECLARE @ColName VARCHAR(64)
  
  SET @ColName='intcolumn'
  
  SET @intParam = SELECT @ColName FROM myTable
  </code></pre>
  
  <p>How do I accomplish something like this? I can see the problem is that the SELECT statement simply returns the column name as a string, but I am not sure how to fix that. I am using SQL Server 2008R2.</p>