|
|
 |
| SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |
|

May 26th, 2006, 04:24 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
stored procedure with two result sets
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
|

May 26th, 2006, 09:04 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2005
Location: , AZ, .
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
CREATE TABLE #FileList (Files varchar(8000))
INSERT #FileList (Files)
EXEC master.dbo.xp_cmdshell 'dir c:\'
David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com
|

May 26th, 2006, 09:22 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I don't understand. You called proc to fill table.That is ok but as I said I have one procedure wich I can not change, then that proc returns two sets, then I need second set for some calculations in my proc, then I need data from exactly that procedure wich returns two sets.
|

May 29th, 2006, 06:33 PM
|
|
Friend of Wrox
|
|
Join Date: Dec 2005
Location: , AZ, .
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry joxa83 -- I must have misunderstood the problem. You could call it from a client app, get the second result set and then insert that data into a table.
David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com
|

May 30th, 2006, 04:58 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That is the problem 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, then I need data from exactly that procedure wich returns two sets
|

May 30th, 2006, 05:03 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Forgot to say I can not use front end app.
|

May 30th, 2006, 05:41 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: Helsingborg, , Sweden.
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i don't think there is a way because the two resultsets return different field layouts.
|

May 30th, 2006, 06:38 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes sets have different shemas but there must be a way.
|

June 7th, 2006, 04:36 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am not sure why you would want to combine the two. But I recall I once came up with an obscure need for this. I created a column called RS for result set. Set the value to one for the first result set, to two for the second. added the two result sets together increasing the columns. For example say I do the following two selects.
Select firstname, lastname from x
Select city, state from y
the result set would come out like this.....
rs FirstName LastName City State
1 John doe
1 Susan Smith
1 Pewee Herman
1 Dubya Bush
2 Hollywood CA
2 New York NY
2 Oklahoma City OK
2 Seattle WA
Notice for RS = 1 there are not city or state values, and for RS = 2
there are no names.
You can do this with a temp table probably easiest.
Hope this helps,
Rob
|

June 9th, 2006, 08:20 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Nice solution.Thank You.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |