title: Building a comma separated list?
body: <p>I'm tryin to use SQL to build a comma separated list of cat_id's</p>
  
  <p>the code is:</p>
  
  <pre><code>declare     @output varchar(max)
  set         @output = null;
  select @output = COALESCE(@output + ', ', '') + convert(varchar(max),cat_id)
  </code></pre>
  
  <p>edit: changed '' to null, STILL same.
  but the output im getting is like so:</p>
  
  <pre><code>, 66 , 23
  </code></pre>
  
  <p>the leading comma should not be there. What have i missed?</p>