declare cur3_5 cursor for select distinct(cr.id) from ahd.ahd.call_req as cr left outer join ahd.ahd.ztr_his as zh on cr.persid=zh.call_req_id where cr.type='i' and cr.open_date>@begin and cr.open_date<@end and zh.to_cnt = @userid
open cur3_5
set @total = @@cursor_rows
close cur3_5
deallocate cur3_5
insert into #temp_proc3 values (@userid , @handled , @total)
fetch next from cur3_2 into @userid
end
close cur3_2
deallocate cur3_2
select * from #temp_proc3
drop table #temp_proc3
d:将日期格式转换成整型
fgw_util1.txt
--fgw_util1
create procedure [ahd].[fgw_util1] (@time datetime, @seconds int output)
as
set @seconds=datediff(ss,'1970-01-01 00:00:00', @time)
go