Comma separated values of table column in sql server
Hi Friends,
Today i came across one interesting inbulit function of sql that is 'COALESCE'. Using which i can get comma separated values of a column in sql table. I have explained how its been possible to me. Please have a look below.
SELECT * FROM university; DECLARE @universityList varchar(100); SELECT @universityList = COALESCE(@universityList + ',', '') + CAST((universityName) AS varchar(5)) FROM university SELECT @universityList as CSV;
