Making a tiny modification to this answer, you have STRAGG functionality in SqlServer:
CREATE TABLE yourtable
([FieldA] int, [FieldB] varchar(1))
;
INSERT INTO yourtable
([FieldA], [FieldB])
VALUES
(1, 'A'),
(1, 'B'),
(2, 'A')
;
select distinct t1.FieldA,
STUFF((SELECT distinct ',' + t2.FieldB
from yourtable t2
where t1.FieldA = t2.FieldA
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'') data
from yourtable t1;
As usual, however, this ended up making me raise another question, still waiting for an answer :-)
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteASP.NET MVC Training in Chennai
ASP.NET MVC Online Training | Online LINQ Training