OK, I modified my nested cursor to retrieve this information. Everything is being placed into the temp table first, but I can still get no data from the cursor in the query or in the report.
WHAT am I missing
WHAT am I missing
Code:
Declare @DT datetime
DECLARE @apDate nvarchar(15)
declare @ApName nvarchar (100)
Declare @ApAge int
Declare @ApPat bigint
Declare @apAcct bigint
declare @ApSt nvarchar(15)
Declare @ApCh bigint
Declare @ApIP char(10)
Declare @ApUnit int
Declare @ApCP nvarchar (15)
declare @rptdt nvarchar (15)
set @rptdt = '02/17/05'
declare @DocID bigint
declare @olddoc bigint
set @olddoc = ''
set @rptdt = ISNULL(CONVERT(nvarchar, @RptDt, 1), '')
Declare @AptTbl table
(Starttm datetime,
dr bigint,
apptdt nvarchar(15),
appttime nvarchar(15),
PName nvarchar(100),
Page int,
PNo bigint,
AcctNO bigint,
Chair Bigint,
IP Char(10),
ConfirmPhone nvarchar(15),
UTP int)
Insert @Apttbl
select Distinct(Starttime), dr, apptdt, Appttime, [name], age,patientno, accountno, chair,IP, confirmphone, UTP from vappointments where
apptdt = @rptdt order by dr, appttime
select top 1 @olddoc = dr from @apttbl order by dr, appttime
--select * from @AptTbl
declare acurPat CURSOR for select * from @apttbl order by dr, appttime
open AcurPat
while @@FETCH_STATUS = 0
BEGIN
--if @olddoc = @docid
begin
fetch from acurpat into
@DT,
@docid,
@apdate,
@apst,
@apname,
@apage,
@appat,
@apacct,
@apch,
@apip,
@apCP,
@apUnit
select @DT,
@docid,
@apdate,
@apst,
@apname,
@apage,
@appat,
@apacct,
@apch,
@apip,
@apCP,
@apUnit
fetch next from acurpat into
@DT,
@docid,
@apdate,
@apst,
@apname,
@apage,
@appat,
@apacct,
@apch,
@apip,
@apCP,
@apUnit
end
close acurpat
deallocate acurpat
end