p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > SQL Server > SQL Server 2000 > SQL Server 2000
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 26th, 2006, 04:24 AM
Authorized User
Points: 184, Level: 3
Points: 184, Level: 3 Points: 184, Level: 3 Points: 184, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old 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
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old May 26th, 2006, 09:22 AM
Authorized User
Points: 184, Level: 3
Points: 184, Level: 3 Points: 184, Level: 3 Points: 184, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old 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
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old May 30th, 2006, 04:58 AM
Authorized User
Points: 184, Level: 3
Points: 184, Level: 3 Points: 184, Level: 3 Points: 184, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old May 30th, 2006, 05:03 AM
Authorized User
Points: 184, Level: 3
Points: 184, Level: 3 Points: 184, Level: 3 Points: 184, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default

Forgot to say I can not use front end app.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old May 30th, 2006, 05:41 AM
Friend of Wrox
Points: 751, Level: 10
Points: 751, Level: 10 Points: 751, Level: 10 Points: 751, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2006
Location: Helsingborg, , Sweden.
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i don't think there is a way because the two resultsets return different field layouts.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old May 30th, 2006, 06:38 AM
Authorized User
Points: 184, Level: 3
Points: 184, Level: 3 Points: 184, Level: 3 Points: 184, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default

yes sets have different shemas but there must be a way.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old June 7th, 2006, 04:36 PM
Friend of Wrox
Points: 807, Level: 11
Points: 807, Level: 11 Points: 807, Level: 11 Points: 807, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #10 (permalink)  
Old June 9th, 2006, 08:20 AM
Authorized User
Points: 184, Level: 3
Points: 184, Level: 3 Points: 184, Level: 3 Points: 184, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: Serbia, Belgrade
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to joxa83 Send a message via Yahoo to joxa83
Default

Nice solution.Thank You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure Help. midway11 SQL Language 3 November 20th, 2006 06:36 AM
Stored Procedure Help BukovanJ SQL Language 2 October 10th, 2006 09:02 AM
Chapter 12 - Multiple Active Result Sets mdrake BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 9 May 13th, 2006 07:33 AM
Stored Procedure rajanikrishna SQL Server 2000 0 July 18th, 2005 06:01 AM
Stored Procedure... babloo81 SQL Server 2000 2 May 2nd, 2004 12:25 AM



All times are GMT -4. The time now is 08:03 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc