Using COALESCE function to make values separated with commas

后端 未结 4 1291
走了就别回头了
走了就别回头了 2020-11-28 08:14

I have a table (EMP) I know that using the COALESCE function we can get the values of any column in this way

23,23,45,34

SELECT          


        
4条回答
  •  独厮守ぢ
    2020-11-28 08:33

    Isnull Function will also give us the same result

    DECLARE @List VARCHAR(8000)
    
    SELECT @List = ISNULL(@List + ',', '') + CAST(OfferID AS VARCHAR)
    FROM   Emp
    WHERE  EmpID = 23
    
    SELECT @List 
    

提交回复
热议问题