title: SQL Server variables
body: <p>Why do these queries return different values? The first returns a result set as expected, but the second (which as far as I can tell is exactly the same) does not. Any thoughts?</p>
  
  <p><strong>1:</strong></p>
  
  <pre><code>declare @c varchar(200)
  
  set @c = 'columnName'
  
  select top 1 * 
  from myTable 
  where @c is not null 
        and len(convert(varchar, @c)) &gt; 0
  </code></pre>
  
  <p><strong>2:</strong></p>
  
  <pre><code>SELECT top 1 * 
  FROM myTable 
  WHERE columnName IS NOT NULL 
        and len(convert(varchar,columnName)) &gt; 0   
  </code></pre>