473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
CREATE TABLE [pp] (
[aa] [int] NULL ,
[cc] [int] NULL
) ON [PRIMARY]
GO

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

--proc1
create PROCEDURE prc_1
(@date1 smalldatetime,
@date2 smalldatetime)
AS
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 @RC int
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(nvarchar, @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 3674

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

Similar topics

2
by: tedsuzman | last post by:
----- def f(): ret = 2 exec "ret += 10" return ret print f() ----- The above prints '12', as expected. However,
45
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)
7
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...
10
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...
10
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...
4
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:...
2
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 :...
5
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
4
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()
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.