SubjectID       StudentName
----------      -------------
1               Mary
1               John
1               Sam
SubjectID       StudentName
----------      -------------
1               Mary, John, Sam
Hi, i'm using SQL Server 2014. I would like to know if it's possible to use the STUFF() function to insert the result into one column. The examples i see online are all retrieving. I tried to do it based on the documentation by it doesn't seems to be correct.
Query
 @"INSERT INTO ApplicationOtherInfo 
                        (ApplicationId, AppOptionCode
                         ) values 
                        (@applicationId, @appCode
                         )";
SELECT STUFF((SELECT ',' + AppOptionCode
              FROM ApplicationOtherInfo 
              ORDER BY AppOptionCode
              FOR XML PATH('')), 1, 1, '') 
 
    