title: SQL using variable in SELECT
body: <p>I can copy a row and change the value of a single field in the same table like this which works perfectly fine:</p>
  
  <pre><code>INSERT INTO myTable (foo,bar)
      SELECT foo,'new bar'
      FROM myTable
      WHERE rowIndex=5
  </code></pre>
  
  <p>But I'd like to replace <code>'new bar'</code> with an inline variable. I have tried this to no avail:</p>
  
  <pre><code>DECLARE @Bar varchar(50) = 'new bar'
  INSERT INTO myTable (foo,bar)
      SELECT foo,@Bar
      FROM myTable
      WHERE rowIndex=5
  </code></pre>
  
  <p>I just get thrown an error that says <code>@Bar</code> is an invalid column.</p>
  
  <p>Is there a way to do this?</p>