title: Basic T-SQL Pass variable to LEFT
body: <p>this seems really basic, but why does this not work?</p>
  
  <pre><code>DECLARE @Test1 INT
  DECLARE @Test2 NVARCHAR
  SELECT @Test1 = CHARINDEX('_', 'x1Left_r2Right')-1
  SELECT @Test2 = LEFT('x1Left_r2Right', @Test1)
  PRINT @Test1
  PRINT @Test2
  </code></pre>
  
  <p>if your following my logic, the result should be 'x1Left', however it seems <code>@Test</code> always evalutes to 1 in the second select even though it contains a 6.  </p>
  
  <p>This is the current output:</p>
  
  <pre><code>6
  x
  </code></pre>
  
  <p>i'm on sql-server 2014.</p>