Concatenate a selected column in a single query?

前端 未结 6 723
别跟我提以往
别跟我提以往 2020-12-21 21:47

I know you can do this, because I\'ve seen it done once before, but I forget where and up until now I haven\'t need to do it.

I have a table called Employees, and it

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 22:19

    Use coalesce. Something like this:

    DECLARE @Names varchar(1000)
    SELECT @Names = COALESCE(@Names + ', ', '') + Name
    FROM Employees
    

提交回复
热议问题