title: Use a varchar local variable in WHERE clause
body: <p>I am using SQL server for this query... I will be creating several SELECT statements which will utilize the same portion of a WHERE clause. So far, I have declared a vachar variable to include in the WHERE clause but I am receiving an error. This is what I have tried so far:</p>
  
  <pre><code>DECLARE @PersonalLoans varchar(500) = 'code = ''RTR'' OR 
  code = ''RTL'' OR 
  code = ''LRV'' OR 
  code = ''LPV'' OR 
  code = ''LN'' OR 
  code = ''LFR'' OR 
  code = ''LCV'''
  
  DECLARE @L01 int = 0
  SELECT @L01 = ROUND(SUM(balance)*-1,2) FROM loan WHERE @PersonalLoans AND paydue &gt; @databasedate      
  PRINT '"L01": ' + CAST(@L01 AS varchar(15)) + ';'
  </code></pre>
  
  <p>I am receiving an error at the WHERE clause:
  An expression of non-boolean type specified in a context where a condition is expected.</p>
  
  <p>I've done some research and come across the EXEC function but I need to be able to add the "AND paydue > @databasedate" to the WHERE clause. I will need to use the @PersonalLoans variable several times and append different AND clauses to it throughout the query.</p>