Answers for "tsql join multiple record in one string"

SQL
1

tsql join multiple record in one string

Select CountryName from Application.Countries 
 
Declare @val Varchar(MAX); 
Select @val = COALESCE(@val + ', ' + CountryName, CountryName) 
        From Application.Countries Select @val;
Posted by: Guest on June-01-2020
2

tsql join multiple record in one string

-- Concatenates results into one single varchar with separator
SELECT LISTAGG(column_name, ',') WITHIN GROUP (ORDER BY column_name)
FROM YOUR_TABLE;
Posted by: Guest on January-22-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language