Here is a simple way to make a single row value from multiple rows with a separator in SqlServer.
I have a table like the following…
Table Name: People
{codecitation class="brush: sql; gutter: true;" width="500px"}
select * from people
{/codecitation}
 Now I need the ‘Name’ column values where matching the value of ‘aaaa’ in to a single row. For this I have tried to make a query.
Just use the following query to get the solution.
{codecitation class="brush: sql; gutter: true;" width="500px"}
declare @res varchar(1000) select @res = coalesce(@res + ',', '') +Name from people WHERE Name = 'aaaa'
select @res {/codecitation}
Result 
...S.VinothkumaR.
|