我正在使用pyodbc從Microsoft SQL Server中檢索數據。該查詢是採用以下形式pyodbc&MS SQL Server - 「沒有結果,以前的SQL不是查詢。」
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忽略警告?
請注意,我沒有權限更改存儲的過程。
你的語句之間不需要分號嗎? ';'?我真的在問。我不知道。 –
@JoeFrambach:不,不需要分號。 –