Concatenating Row Values

試著忘記壹切 提交于 2019-12-02 09:49:44

This is a technique that should work for you. You can execute this in one batch statement if you wish:

DECLARE @EmployeeList varchar(100)

SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') + 
   CAST(Emp_UniqueID AS varchar(5))
FROM SalesCallsEmployees
WHERE SalCal_UniqueID = 1

SELECT @EmployeeList

For more information, see Using COALESCE to Build Comma-Delimited String.

FOR XML PATH

is not available in sql server 2000.

This article discusses different approached for concatenating row values: Concatenating Row Values in Transact-SQL

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!