Concatenating Row Values

前端 未结 2 1339
独厮守ぢ
独厮守ぢ 2021-01-26 16:57

I was using Microsoft SQL server 2005 and was able to concatenate row values based on the following query:

SELECT e1.EMP_ID,
( SELECT cast(Sector_ID as v         


        
相关标签:
2条回答
  • 2021-01-26 17:32
    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

    0 讨论(0)
  • 2021-01-26 17:42

    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.

    0 讨论(0)
提交回复
热议问题