我正在从Jupyter调用SQL Server SP,并且SP看起来像这样:
ALTER
procedure [dbo].[proc_Report_QuarterlyDistribution02] (@quarter int, @year int, @group int)
as
declare @total int,
@date date
set @date = cast(@year as varchar(4)) + '-01-01'
set @date = dateadd(quarter, @quarter - 1, @date)
print @date
select @total = count(1)
from DimMedical
where ServiceDate between
DATEADD(quarter, -9,@date) and @date
and carriercode = @group
and Category = 'Physicians'
SP继续运行-这不是问题。
问题在于线路
print @date
问题:为什么打印语句会导致错误:
ResourceClosedError: This result object does not return rows. It has been closed automatically.
答案 0 :(得分:1)
为什么打印语句会导致错误:“此结果对象不返回行”
这可能是您正在使用的客户端库中的限制。某些客户端库在看到消息时会停止寻找结果集。
要么删除打印语句,升级客户端库(未提及),要么使用INSERT…EXEC将存储过程插入表中,然后在后续查询中从中选择。