eZeeNow.com

it's your's

Convert/Cancatenate rows to column in SQL (COALESCE)

Using COALESCE we can convert rows to column.
 In the query I am using ',' as the delimiter.

DECLARE @AccountNumber nvarchar(max)
SELECT @AccountNumber = COALESCE(@AccountNumber+ ',', '') + AccountNumber
FROM AccountDetail

Select @AccountNumber as AccountNumberLIST



OUTPUT



Loading