WHERE TutorID IN (SELECT Value from dbo.fnSplit(@TutorIDs, ',') -- here we need to add one more )I also don't like IN solution that much. I prefer using EXISTS operator.
>>set nocount on >>set statistics io on >>set statistics time on >>query 1 >>query 2 >>query 3 >>>>
>Msg 156, Level 15, State 1, Procedure AppointmentsSelectByTutorsPlusStudentID, Line 19 >Incorrect syntax near the keyword 'OR'. >>
>CREATE PROCEDURE [dbo].[AppointmentsSelectByTutorsPlusStudentID] >( > @TutorIDs varchar(500), > @StudentID char(5) >) >AS >BEGIN > SET NOCOUNT ON; > > SELECT > AppointmentID, > TutorID, > Description > FROM [dbo].[Appointment] > WHERE > TutorID IN (SELECT Value from dbo.fnSplit(@TutorIDs, ',') OR > AppointmentID IN (SELECT AppointmentID FROM StudentAppointments WHERE StudentID = @StudentID) > >END >>Thanks