December 30, 2022 at 2:04 pm
Hi,
this is my Query.
create table #emp( sal int)
insert into #emp(sal)
values (1000),(2000),(3000),(5000)
select * from #emp
data:
1000
2000
3000
4000
exptext output ::
1000,2000,3000,5000
December 30, 2022 at 4:15 pm
Here's the solution to the problem you posted.
SELECT CSV = STRING_AGG(sal,',')
FROM #emp
;
There are more powerful uses for the STRING_AGG() function if you have a look at the MS Doc on the subject.
https://learn.microsoft.com/en-us/sql/t-sql/functions/string-agg-transact-sql
--Jeff Moden
Change is inevitable... Change for the better is not.
January 3, 2023 at 9:05 am
thank you
January 6, 2023 at 6:26 am
This was removed by the editor as SPAM
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply