CREATE FUNCTION Get_ProceduresOnCase (@tiMeetID int) RETURNS varchar(1000) AS BEGIN declare @tcProcDesc varchar(200) Declare @returnValue varchar(1000) declare @tiRows int declare @tiCtr int set @tiCtr=1 declare CaseProcs cursor local for select rtrim(Description) from meetings mx inner join meetproc mp on mp.meetingnumber=mx.meetingnumber where mx.meetingNumber = @tiMeetID order by mp.sysorder -- Open our cursor and determine how many rows are in it Open CaseProcs set @tiRows=@@cursor_rows -- Loop Through the Cursor while (@tiCtr <= @tiRows) Begin fetch CaseProcs into @tcProcDesc set @returnValue=@returnValue+rtrim(@tcProcDesc)+', ' end -- Close the Cursor Close CaseProcs DeAllocate CaseProcs return (@returnValue) END