title: How to declare and set a variable equal to a list of values?
body: <p>Good morning everyone! I am trying to write a Query that accepts a list of zip codes as a variable, and then queries for values in that set. Everything seems to be working fine, except the variable which I have placed my list values into.</p>
  
  <p>I have never tried using a <code>varchar</code> value to represent a list of values, so if it's not possible or if there is a better way, please let me know.</p>
  
  <p>here is the code so far:</p>
  
  <pre><code>DECLARE @trade_firm VARCHAR(20)
  DECLARE @zip_list VARCHAR(255)
  ---------------------------------
  SET @trade_firm = '0016986'
  SET @zip_list = '44654,15219,15219,15219' --this is my list of zip codes
  ---------------------------------
  
  SELECT oad.POSTAL_CODE_1,
        o.CHANNEL
  FROM dbo.OFFICE AS o
      INNER JOIN dbo.OFFICE_ALIAS AS oa
      ON o.OFFICE_ID = oa.OFFICE_ID
      INNER JOIN dbo.OFFICE_ADDRESS AS oad
      ON o.ADDRESS_1_ID = oad.OFFICE_ADDRESS_ID
  WHERE oa.TRADE_FIRM = @trade_firm
  AND o.CHANNEL != (  SELECT f.channel
                  FROM dbo.FIRM AS f
                      INNER JOIN dbo.FIRM_ALIAS AS fa
                      ON f.FIRM_ID = fa.FIRM_ID
                  WHERE fa.trade_firm = @trade_firm)--will return the channel of the main firm
  AND oad.POSTAL_CODE_1 NOT IN @zip_list --this is the variable as I currently have it, broken
  </code></pre>