title: SQL Server variables and direct values not returning same results
body: <p>I'm working on building a sql query to fetch some details from a table. And I am using a variable that is assigned with a value in where condition. However, when the value assigned to the variable is directly given to the where condition it returns a different result set. I cannot disclose the entire query here due to the nature of work but I hope someone could help me.</p>
  <pre><code>declare @filterParam varchar(255) = 'Y'
  Select .......
  from Table A
  where 
  ...
  A.column!= @filterParam
  </code></pre>
  <p>This returns some number of rows but if i replace the variable with its actual value then 0 rows are returned</p>
  <pre><code>Select .......
  from Table A
  where 
  ...
  A.column!= 'Y'
  </code></pre>
  <p>0 rows is what the expected result is. But why is the SQL Server returning result when the value is assigned to a variable and used it against the where condition.</p>
  <p>Thanks in advance.</p>