从存储过程插入表
我正在尝试使用包含两个不同游标的存储过程作为表输入,如下所示:
INSERT INTO table1 EXEC * FROM tblDailySales
存储过程包含两个游标 - 我不只是使用来运行。
我收到以下错误:
名为“csrDistricts”的游标不存在。
我也遇到这个错误
INSERT EXEC
语句不能嵌套
存储过程不包含我可以看到的 EXEC
。
除了简单的SELECT
之外,还有哪些类型的存储过程可以用作表的源?
I am trying to use a stored procedure that contains two different cursors as table input like such:
INSERT INTO table1 EXEC * FROM tblDailySales
The stored proc contains two cursors - I did not run just using.
I get the following error:
A cursor with the name 'csrDistricts' does not exist.
I also, get this error
An
INSERT EXEC
statement cannot be nested
The stored proc contains no EXEC
that I can see.
What kind of stored proc other than simple SELECT
can be used as source for table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
table1 已经定义了吗?如果是这样,您现在需要做的就是
,诀窍是,存储过程将只能返回一个结果集并插入到表中。
如果需要插入两个不同的结果集,则必须将它们收集在两个不同的存储过程中,然后运行两个 INSERT 语句。
如果您必须立即执行这些操作,则需要从存储过程中执行插入操作。
Is table1 already defined? If so all you should have to do is
Now, the trick is, the stored procedure will only be able to return one result set and insert into the table.
If you need to insert two different result sets, you'll have to gather then in two different stored procedures, then run two INSERT statements.
If you must do them at once, you'll need to do the insert from within the stored procedure.