Building a comma separated list?

前端 未结 9 1484
说谎
说谎 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条回答
  •  情书的邮戳
    2020-11-30 09:25

    COALESCE Returns the first nonnull expression among its arguments

    First argument @output + ', ' is never null (unless you initialize @output as null AND set CONCAT_NULL_YIELDS_NULL to ON), so it's always returned.

提交回复
热议问题