Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #699

Re: Trying to understand 400 line stored procedure

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Trying to understand 400 line stored procedure
Date 2011-10-02 14:29 +0200
Organization Erland Sommarskog
Message-ID <Xns9F72937972F25Yazorman@127.0.0.1> (permalink)
References <e69f875eoqplodjkvto1tcghs6rlf9beu0@4ax.com>

Show all headers | View raw


Tony C. (me@here.com) writes:
> 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@sommarskog.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

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Trying to understand 400 line stored procedure Tony C. <me@here.com> - 2011-10-01 18:48 -0500
  Re: Trying to understand 400 line stored procedure Erland Sommarskog <esquel@sommarskog.se> - 2011-10-02 14:29 +0200
    Re: Trying to understand 400 line stored procedure Tony C. <me@here.com> - 2011-10-02 08:29 -0500

csiph-web