Building a comma separated list?

前端 未结 9 1483
说谎
说谎 2020-11-30 08:49

I\'m tryin to use SQL to build a comma separated list of cat_id\'s

the code is:

declare     @output varchar(max)
set         @output = null;
select @         


        
9条回答
  •  猫巷女王i
    2020-11-30 09:40

    And sometimes...

    you have to answer your own question

    declare     @output varchar(max)
    select      @output = case when (@output is null) then '' else ', ' END + convert(varchar(max),cat_id)
    

提交回复
热议问题