CREATE PROC [dbo].[sp_STUD1_GetReportNotesPrepOtherSubject]
( @itemId INT )
AS
SELECT STUFF((SELECT	'<br/> '+P.Prep2017_SessionReviewTool_Date+': ' + P.Prep2017_SessionReviewTool_OtherSubjectNote [Note]
		FROM	dbo.qt_PrepProgramme2017 P
				CROSS APPLY (SELECT splitdata FROM dbo.SplitString(P.surfaceLinkItems, ',')) X 
				JOIN dbo.pal_SurfaceItem I
					ON I.surfaceId = (SELECT recId FROM pal_Surface WHERE name = 'Profiles')
					AND I.recId = X.splitdata
		WHERE	I.recId = @itemId
				AND LEN(P.Prep2017_SessionReviewTool_OtherSubjectNote)>0
		ORDER BY P.Prep2017_SessionReviewTool_Date
        FOR XML PATH(''), TYPE
        ).value('.', 'NVARCHAR(MAX)') 
    ,1,5,'')
GO


