INSERT EXEC语句不能嵌套 [英] An INSERT EXEC statement cannot be nested

查看:377
本文介绍了INSERT EXEC语句不能嵌套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解决此错误不能嵌套INSERT EXEC语句?"
我的程序就像.

How can I solve this error "An INSERT EXEC statement cannot be nested?"
My procedure is like.

CREATE PROCEDURE [dbo].[Procedure3]

   @para1 varchar(50),
   @para2 datetime
   
AS
BEGIN
CREATE TABLE #tem
(
 ….
 ….
)
insert into #tem (value) exec [dbo].[Procedure2] @para1,@para2,@para3
…….
…….
……….

END



在此存储过程[dbo]中.[Procedure2]我们有



And inside this stored procedure [dbo].[Procedure2] we have

CREATE PROCEDURE [dbo].[Procedure2]

   @para1 varchar(50),
   @para2 datetime,
   @para3 decimal(18,2)

AS
BEGIN
CREATE TABLE #temp
(
 Value decimal(18,2)
)
insert into #temp exec Procedure1 @para1,@para2,@para3
……..
…….
……..
select Name,Amount from #Temp1


END


可能吗?如果是,那么怎么办?


Is it possible? If yes, then how?

推荐答案

您做错了...如果我没有记错,您正在尝试将存储过程的结果插入到临时表中.您可以用不同的方式实现相同的目的...

签出:
1. http://sqlserverplanet.com/sql/insert-stored-procedure-results-into -table/ [^ ]
2. http://blog .coryfoy.com/2005/07/inserting-the-results-of-stored-procedure-to-a-temp-table/ [ http://barry-king.com/2008 /05/06/insert-into-temporary-table-from-stored-procedure/ [ http://www.informit.com/articles/article.aspx?p= 25288& seqNum = 6 [ ^ ]

希望这会有所帮助.
一切顺利.
You are doing it wrong... If I am not wrong you are trying to insert the result of stored procedure into a temp table. You can achieve the same thing but in a different way...

Check out :
1. http://sqlserverplanet.com/sql/insert-stored-procedure-results-into-table/[^]
2. http://blog.coryfoy.com/2005/07/inserting-the-results-of-a-stored-procedure-to-a-temp-table/[^]
3. http://barry-king.com/2008/05/06/insert-into-temporary-table-from-stored-procedure/[^]
4. http://www.informit.com/articles/article.aspx?p=25288&seqNum=6[^]

Hope this helps.
All the best.


这篇关于INSERT EXEC语句不能嵌套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆