dbTalk Databases Forums  

Trying to understand 400 line stored procedure

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Trying to understand 400 line stored procedure in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tony C.
 
Posts: n/a

Default Trying to understand 400 line stored procedure - 10-01-2011 , 06:48 PM






Hi,
I'm trying to understand a large storedprocedure with multiple
select statments like around 15 or so. I'm a little new to multiple
result sets.



The reader populates fields by incrementing an integer index for each
field in a row not by table tnames

The read uses nextresult() to move to the next restult set....

My Question is: Is the order of the resultsets in the Reader the same
as the order of Select statements in the stored procedure? I suppose
I should have a result set for every select statement?

Just wondered how this stuff works.

Thanks,
Tony C.

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Trying to understand 400 line stored procedure - 10-02-2011 , 07:29 AM






Tony C. (me (AT) here (DOT) com) writes:
Quote:
The reader populates fields by incrementing an integer index for each
field in a row not by table tnames

The read uses nextresult() to move to the next restult set....

My Question is: Is the order of the resultsets in the Reader the same
as the order of Select statements in the stored procedure? I suppose
I should have a result set for every select statement?
Yes, the result sets are returned in the reader, in the order they are
produced in SQL Server. Note that it is the run-time order that matters.
That is, if the code goes:

CREATE PROCEDURE baaaaad_sp AS
GOTO bottom
top: SELECT 989 AS xyz
RETURN
bottom: SELECT getdate() AS now
GOTO top

The first result set will be the date, and the second result set will the
number.




--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
  #3  
Old   
Tony C.
 
Posts: n/a

Default Re: Trying to understand 400 line stored procedure - 10-02-2011 , 08:29 AM



Thank you Very Much!
Tony C.

Reply With Quote
Reply




Thread Tools
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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.