Introduction
This blog describes how to get Comma Separated data from the table. Content will be added soon. If you are familiar with this, please consider adding any troubleshooting tips that may help the community.
Created one example table
- CREATE TABLE Articles
- (
- Title VARCHAR(50),
- ArticleType VARCHAR(10),
- Tags VARCHAR(500)
- )
- insert into Articles values('test article title-01','C','C')
- insert into Articles values('test article title-01','C','C++')
- CREATE FUNCTION dbo.MakeCommaValue (@pC2 AS VARCHAR(10))
- RETURNS VARCHAR(8000)
- AS
- BEGIN
- DECLARE @oResult VARCHAR(8000)
- SELECT @oResult= COALESCE(@oResult+',','')+CAST(Events AS VARCHAR(10))
- FROM Articles WITH (NOLOCK)
- WHERE ArticleType = @pC2
- ORDER BY Tags
- RETURN @oResult
- END
- --Call the Function like this
- SELECT DISTINCT Title,ArticleType,dbo.MakeCommaValue('B') as 'Tags' FROM Articles
| Title | ArticleType | Tags |
| test article title-01 | c | C, C++ |

Join the conversation! Your thoughts help the community grow.