我正在使用 pyodbc 从 Microsoft SQL Server 检索数据。查询格式如下
SET NOCOUNT ON --Ignore count statements
CREATE TABLE mytable ( ... )
EXEC some_stored_procedure
INSERT mytable
--Perform some processing...
SELECT *
FROM mytable
存储过程对包含NULLs
发出表单警告的值执行一些聚合Warning: Null value is eliminated by an aggregate or other SET operation.
。这导致 pyodbc 无法使用错误消息检索数据No results. Previous SQL was not a query.
我试图通过设置来禁用警告SET ANSI_WARNINGS OFF
。但是,查询随后会失败并显示错误消息Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
。
是否有可能
- 禁用警告
- 还是让 pyodbc 忽略警告?
请注意,我没有更改存储过程的权限。