DECLARE @DOS as datetime
,@CII2T as datetime
,@CII2I as datetime
,@CID as varchar(10)
,@CDOS as datetime
,@TCA as money
,@TPA as money
,@PD as datetime
,@ApptID as varchar(10)
SELECT @ApptID = id FROM [dbo].[Appointments] WHERE start_date = '20200608' and patient_person_id = '35576'
--EXEC GetAppointmentEfficiency (SELECT id FROM [dbo].[Appointments] WHERE start_date = '20200608' and patient_person_id = '35576')
EXEC GetAppointmentEfficiency @ApptID
The EXEC using the declared variable @ApptID works.
The EXEC using the SELECT that populates the @ApptID to provide the same value does not.
I get the following error message: Msg 102, Level 15, State 1, Line 19
Incorrect syntax near ','.
What am I missing? My intent is to get multiple records of output using the SELECT.
Also, I have tried to use temp tables to store these multiple rows but with no success.