Perhaps not what you want, and maybe a little inefficient, but you could consider:
create function ufn_course_students
(
@course nvarchar(50)
)
returns nvarchar(100)
as
begin
declare @student nvarchar(100)
set @student = ''
select
@student = @student + student + ' '
from studentcourse2
where course = @course
return @student
end
select distinct
course,
dbo.ufn_course_students(course)
from studentcourse2
order by course desc
which will get you what you want.
Not used the "pivot" command before .. but I'm not sure it'll get you what you want. Perhaps someone with more experience than myself can chip in here.
Joe
Enter your message below
Sign in or Join us (it's free).