简体   繁体   English

通过Excel数据连接调用的存储过程失败

[英]Stored Procedure called via Excel data connection fails

I have table in a Excel 2007 workbook. 我在Excel 2007工作簿中有表。 The table has an external SQL data connection to a stored procedure. 该表具有到存储过程的外部SQL数据连接。 Inside the stored procedure I'd like to clear and populate an intermediate table before querying data from it. 在存储过程内部,我想在查询中间表之前清除并填充中间表。

The stored procedure works if I don't have the INSERT statement in it (I insert the data outside Excel), but as soon I try to insert into my temporary table in the stored procedure, I get an error "The query did not run or the database could not be opened" . 如果存储过程中没有INSERT语句(在Excel外部插入数据),则该存储过程有效,但是一旦我尝试将其插入存储过程的临时表中,就会收到错误消息"The query did not run or the database could not be opened"

What's interesting too is that despite the error, the insert inside the stored procedure still gets executed - the data is there after the error. 同样有趣的是,尽管有错误,但存储过程中的插入仍然会执行-错误发生后数据就在那里。 Anybody knows how I can do the insert without triggering the error? 有人知道如何在不触发错误的情况下进行插入吗?

I did some more digging and I came across this article that contained the answer: Running Advanced SQL Stored Procedures from Excel 我做了一些进一步的挖掘,发现包含答案的这篇文章: 从Excel运行高级SQL存储过程

Basically before my insert I have to put SET NOCOUNT ON and after the insert, I add SET NOCOUNT OFF. 基本上,在插入之前,我必须将SET NOCOUNT设置为ON,然后在插入之后,将SET NOCOUNT设置为OFF。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM