title: dynamic column name in where clause
body: <pre><code>declare @temp varchar(20)
  declare @name varchar(20)
  set @name = 'John'
  set @temp  = 'e'
  select * from TableA
      where   case when @temp = 'e' then [em_name]
            case when @temp = 'c' then [company_name] 
          end
            = @name
  </code></pre>
  
  <p>This query is giving me error(A non-Boolean expression in where clause).</p>
  
  <p>Please explain what is wrong in this query and how can i achieve this without dynamic sql.</p>
  
  <p>so when i give <code>@temp  = 'C'</code> then it should search for <code>[company_name] = @name</code>. and have a long list of <code>@temp values(employee name, company name, city name, state name, supervisor name etc)</code>.</p>