Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 INSERT EXEC statement cannot be nested

Author  Topic 

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-20 : 06:15:22
Hi

I got this error.. pls helpon this..

Msg 8164, Level 16, State 1, Procedure <sp_create>, Line 52
An INSERT EXEC statement cannot be nested.

MY code is...

WHILE @INT <=ISNULL((SELECT COUNT(ID) FROM table),0)  
BEGIN

SELECT @D_Part_No = D_Part_No FROM <Table>
WHERE ID = @INT


EXEC SP1 @D_Part_No,@MODEL_ID OUTPUT

INSERT INTO #temp_get_forecast(period_id,period_name,forecast_data)
EXEC SP2 @D_Part_No, @MODEL_ID

SET @INT = @INT + 1

END


-------------------------
R..

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-20 : 06:29:14
Rewrite your SP1 or SP2 to not have an "insert into".



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-20 : 06:51:51
hi

Am not getting your point... please can you explain about the error...what i did wrongly in my proc..

-------------------------
R..
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-20 : 06:59:31
You already have an "INSERT INTO" in your SP2 code.
And they cannot be nested, you cannot use SP2 with another INSERT INTO.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -