...[name], age,patientno, accountno, chair,IP, confirmphone, UTP from vappointments where
@DT = ISNULL(CONVERT(nvarchar, @RptDt, 1), '')/* and Dr = @docID*/ order by dr, appttime
declare acurPat CURSOR for select Distinct(Starttime), dr, apptdt, Appttime, [name], age,patientno...