Combine column values as one string

You can use T-Sql’s COALESCE function to combine your data into a single string. Here is a simple sample: 

DECLARE @str VARCHAR(100)

SELECT @str = COALESCE(@str + '|', '') + Firstname
FROM Members with(nolock)

Print @str

Result:

Ilbay|Talha|Roberte|Theıoden|Cihan|Sagolee|Kazım|Mehmet|Recep|Alp|Haci|Ömer

Happy coding…

Posts created 141

Leave a Reply

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top