Get Column values in a single coma separated string in SQL Server


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


ComaImg.png


Reference From : http://www.c-sharpcorner.com/Blogs/9637/get-a-column-value-in-a-single-coma-separated-string-in-sql.aspx









Comments

Popular posts from this blog

Find procedure and function in SQL Server

Windows Service Install and Un Install in MS VisualStudio 2010

Find Store Procedures and Functions in MS SQL Server.