473,883 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About: An INSERT EXEC statement cannot be nested.

Hi all,
When I use following sql to get data in stored procedure, error occurs:
insert into #tmp
EXECUTE dbo.prc_1 @date1,@date1

Here is the source code, Thanks
[aa] [int] NULL ,
[cc] [int] NULL

insert into pp values(1,2)
insert into pp values(11,22)
create PROCEDURE prc_2
(@date1 smalldatetime,
@date2 smalldatetime)
create table #tmp (aa int, bb int)
insert into #tmp
EXECUTE dbo.prc_1 @date1,@date1
select * from #tmp
drop table #tmp

create PROCEDURE prc_1
(@date1 smalldatetime,
@date2 smalldatetime)
declare @sql Nvarchar(2000)
create table #t2 (aa int, bb int)
set @sql = ''
set @sql = 'insert into #t2 select aa,cc from pp'
exec sp_executesql @sql
select * from #t2
drop table #t2
Here is the error message:
DECLARE @date1 datetime
DECLARE @date2 datetime
SELECT @date1 = '20050101'
SELECT @date2 = '20050303'
EXEC @RC = [ExportServerDB].[dbo].[prc_2] @date1, @date2
DECLARE @PrnLine nvarchar(4000)
PRINT 'Stored Procedure: ExportServerDB. dbo.prc_2'
SELECT @PrnLine = ' Return Code = ' + CONVERT(nvarcha r, @RC)
PRINT @PrnLine

Server: Msg 8164, Level 16, State 1, Procedure prc_1, Line 15
An INSERT EXEC statement cannot be nested.
(0 row(s) affected)
(0 row(s) affected)

Stored Procedure: ExportServerDB. dbo.prc_2
Return Code = 0

Does anyone have some comments about it? Thans
Nov 28 '05 #1
0 3756

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: tedsuzman | last post by:
----- def f(): ret = 2 exec "ret += 10" return ret print f() ----- The above prints '12', as expected. However,
by: It's me | last post by:
I am new to the Python language. How do I do something like this: I know that a = 3 y = "a" print eval(y)
by: Bill Kellaway | last post by:
Hi there - this should be fairly simple for someone. Basically I can't figure out how to pass the parameters from ASP to a Stored Procedure on SQL. Here's my code: I just need to help in learning how to pass these varibables from ASP to the SP.
by: ree32 | last post by:
I am inserting a record into a table that automatically generates unique ids (i.e. Primary Key). Is there anyway to return this id. As I am using this on ASP.net page and I really need the ID to update the page with the new details. I think on mysql there is something called LAST_INSERT_ID which does this.
by: John A Fotheringham | last post by:
I'm trying to write a procedure that having created a new database, will then create within that new database all the tables and procedures that go with it. In doing this I'm hitting the problem that you can't issue a USE command within a procedure. So my question is either - how do I get around this?
by: teddysnips | last post by:
I am trying to insert a row into a table using a stored procedure and I get the following error if I try this from QA: INSERT failed because the following SET options have incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'. If I try to run this from Microsoft Access, I get a slightly different error: INSERT failed because the following SET options have incorrect
by: Scarab | last post by:
Hi,all, When I use following sql, an error occurs: insert into #tmprep EXECUTE proc_stat @start,@end There is a "select * from #tmp " in stored procedure proc_stat, and the error message is : Server: Msg 8164, Level 16, State 1, Procedure proc_stat, Line 42 An INSERT EXEC statement cannot be nested.
by: TPJ | last post by:
I have the following code: ----------------------------------- def f(): def g(): a = 'a' # marked line 1 exec 'a = "b"' in globals(), locals() print "g: a =", a
by: carl.dhalluin | last post by:
Hello I am completely puzzled why the following exec code does not work: mycode = "import math\ndef f(y):\n print math.floor(y)\nf(3.14)" def execute(): exec mycode execute()
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.