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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stored procedure with two result sets

Status
Not open for further replies.

joxa83

Programmer
Nov 30, 2005
7
YU

Is there possible two fill table with second result set returned by stored proc.For instance
create proc test
as
begin
select *from orders

select *from Employees
end

insert into sometable exec test

So I want to fill table 'sometable' with result set
'select *from Employees'. There by tables 'sometable' and 'Employees' have same shema
 
that is not solution.orders table and Employees
tabel do not have same shema.Besides all that how do you intend to substract data from Employees table using result of stored proc?????

 
that is the problem.i can't make two procedures I need to use existing proc wich returns two sets.Then I need to insert second set into some temp table to make some calculations.It means I can't use front end apps or or create two procs.
 
if you want to insert into sometable all employees that don't have orders you would do something like this

insert sometable
select e.* from employees e left join orders o one.orderid =o.orderid
where o.orderid is null

if you want to insert all employees that have an order then your statement would be

insert sometable
select e.* from employees e join orders o one.orderid =o.orderid


Denis The SQL Menace
SQL blog:
Personal Blog:
 
>>>that is the problem.i can't make two procedures I need to use existing proc wich returns two sets.Then I need to insert second set into some temp table to make some calculations.It means I can't use front end apps or or create two procs.

I am not sure that you can do it straight from SQL


but you can use VB ADO code, look up multiple recordsets in BOL the code is there

Denis The SQL Menace
SQL blog:
Personal Blog:
 
No No proc I gave is just similar to my problem.As I said I have one procedure wich I can not change, then that proc returns two set, then I need second set for some calculations in my proc, than I need data from exactly that procedure wich returns two sets.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top