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 2000 Forums
 SQL Server Development (2000)
 calling nexted stored procedure in insert statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-04 : 09:11:40
tushar writes "Hi,

I have to call a stored procedure in INERT statement.
In the called stored procedure also have a insert which also calls a another stored procedure. each stored procedure returns the value to the calling insert statement.

It gives error while calling second time stored procedure.

Is is possible to call such nested stored procedure?? Is yes how??

e.g.
create proc proc1
insert into table1 exec proc2

create proc proc2
insert into table2 exec proc3 -- gives error here....

create proc proc3
insert into table3 values (1,2,3)"

btrimpop
Posting Yak Master

214 Posts

Posted - 2001-12-04 : 10:04:01
Try having your nested stored procs output the result set to a temp table and then use the temp tables to insert into your tables.

create proc proc1
exec proc2
insert into table1 select * from #temptablefromproc2
exec proc3
insert into table2 select * from #temptablefromproc3
etc.
etc.




"In theory there is no difference between theory and practice. But in practice there is!"



Go to Top of Page
   

- Advertisement -