title: MSSQL Server Incorrect syntax near ','
body: <p>I am using sql server and am trying to see how I can set a variable to a list of locations like such:</p>
  
  <pre><code>Declare @StartDate datetime,
          @EndDate datetime,
          @EmpName varchar(50),
          @LOCID varchar(25);
  
  Set @StartDate = '2016/01/01';
  Set @EndDate = '2019/02/01';
  Set @EmpName = 'David Brierton';
  Set @LOCID =  ('desoto_tickets','ccc_tickets');
  
  select 
    ID,
    requester_name,
    requester_id,
    COUNT(*) as numberOfTickets
  from Tickets
  where created_at between @StartDate and @EndDate
    and requester_name = @EmpName
    and ',' + tags + ',' like '%,' + @LOCID + ',%'
  group by Id, requester_name, requester_id
  </code></pre>
  
  <p>I am getting an error for the comma in <code>Set @LOCID =  ('desoto_tickets','ccc_tickets');</code></p>
  
  <p>Error states:</p>
  
  <blockquote>
    <p>Incorrect syntax near ','.</p>
  </blockquote>
  
  <p>What am I doing wrong here?</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Edit:
  In the database in the tags column each tag is listed like this:
  <code>desoto_counter,desoto_tickets,new_associate_workchecked,new_hire__paperwork_check__transaction_complete___express,newhire_assistance,no_error,ops,walk</code></p>
  
  <p>Each row has a list of tags like this in the database.</p>
  
  <p>New Edit:</p>
  
  <pre><code>    Declare @StartDate datetime,
          @EndDate datetime,
      --  @EmpName varchar(50),
          @LOCID1 varchar(25),
          @LOCID2 varchar(25),
          @LOCID3 varchar(25),
          @LOCID4 varchar(25),
          @LOCID5 varchar(25),
          @LOCID6 varchar(25);
  
  Set @StartDate = '2016/01/01';
  Set @EndDate = '2019/02/01';
  -- Set @EmpName = 'David Brierton';
  Set @LOCID1 =  'desoto_counter';
  Set @LOCID2 =  'lwr_counter';
  Set @LOCID3 =  'nr_tickets';
  Set @LOCID4 =  'ps_tickets';
  Set @LOCID5 =  'sdl_tickets';
  Set @LOCID5 =  'ccc_tickets';
  
  select 
    ID,
    requester_name,
    requester_id,
    COUNT(*) as numberOfTickets,
    case
  when tags like '%,' + @LOCID1 + ',%' then 'CDS'
       tags like '%,' + @LOCID2 + ',%' then 'CLR'
       tags like '%,' + @LOCID3 + ',%' then 'CNR'
       tags like '%,' + @LOCID4 + ',%' then 'CPS'
       tags like '%,' + @LOCID5 + ',%' then 'SDL'
       tags like '%,' + @LOCID6 + ',%' then 'CCC'
  else 'Unknown'
  end [Location],
  from Tickets
  where created_at between @StartDate and @EndDate
   -- and requester_name = @EmpName
    and ',' + tags + ',' like '%,' + @LOCID1 + ',%'
    or ',' + tags + ',' like '%,' + @LOCID2 + ',%'
    or ',' + tags + ',' like '%,' + @LOCID3 + ',%'
    or ',' + tags + ',' like '%,' + @LOCID4 + ',%'
    or ',' + tags + ',' like '%,' + @LOCID5 + ',%'
    or ',' + tags + ',' like '%,' + @LOCID6 + ',%'
  group by Id, requester_name, requester_id
  </code></pre>