We can get all values of a column in a single coma separated string this query.
Declare @id varchar(Max)
Select @id = coalesce(@id + ',' ,'') + Cast(ItCode as varchar(10)) From ItMast
Select @id
After you will get result like this

We can get all value as single string with coma separator using this query.

DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegisterMembers onlyeBook · SQLSupabase in Practice: Build and Ship Production Apps on Postgres, from First Table to LaunchDownload nowWrite a blog post and earn +250 SHARP when it is approved.
Write a blog
Join the conversation! Your thoughts help the community grow.