• If you download this SQLCLR component...

    http://groupconcat.codeplex.com/[/url]

    ...then you can write code like this in SQL Server very similar to what you would expect to be able to write in MySQL. Adding the ability to more easily port MySQL code to SQL Server is part of why I wrote the component.

    CREATE TABLE dbo.x

    (

    Id_student INT,

    Id_subject INT,

    grade VARCHAR(10)

    )

    INSERT INTO dbo.x

    (Id_student, Id_subject, grade)

    VALUES (1, 1, 'Good'),

    (1, 2, 'Fair'),

    (1, 3, 'Poor'),

    (1, 4, 'Good'),

    (1, 5, 'Fair'),

    (1, 6, 'Poor');

    SELECT Id_student,

    'Your performance is ' + grade + ' in ' + GroupConcatTest.dbo.group_concat(Id_subject) AS [Statement]

    FROM dbo.x

    GROUP BY Id_student,

    grade;

    There is an XML method as well. If you download group_concat check in the demo scripts for many comparable examples of using group_concat and the XML method.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato