Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert into myTab exec myProc

Status
Not open for further replies.

liuk

Programmer
Jan 16, 2006
54
IT
Hi,
i have a (quite complex)stored returning two different set of data (different columns). Now i need to call that stored within another one and insert only the first result set into a table

Insert into myTab
Exec myProc

Is it possible?
 
One way: modify sproc to receive optional parameter (code in red represents changes):
Code:
alter proc sprocname (@arguments.... [!], @outputs tinyint = 3[/!])
as
set nocount on
...
[!]if @outputs & 1 = 1
begin[/!]
	-- output 1st set
[!]end[/!]
...
[!]if @outputs & 2 = 2
begin[/!]
	-- output 2nd set
[!]end[/!]
go

By default sproc is backward-compatible... but if you call it with @outputs=1 only 1st set would be returned.

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
thanks vongrunt , that's what i've done!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top