Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @Test TABLE
- (
- Course VARCHAR(10),
- Student VARCHAR(10)
- )
- INSERT @Test
- (Course,
- Student)
- VALUES ('A1',
- 'S1'),
- ('A1',
- 'S2'),
- ('A1',
- 'S3'),
- ('A2',
- 'S4'),
- ('A2',
- 'S5')
- SELECT DISTINCT Course,
- Stuff((SELECT ',' + Student
- FROM @Test T1
- WHERE T1.Course = T2.Course
- FOR XML PATH('')), 1, 1, '')
- FROM @Test T2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement