Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: Trying to understand 400 line stored procedure Date: Sun, 02 Oct 2011 14:29:50 +0200 Organization: Erland Sommarskog Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx04.eternal-september.org; posting-host="nBFDv6s1VJQDuF1w6hpX2A"; logging-data="5278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VzN5rCIgLUPVd8GVk118C" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:7IpKVpB1CgaUm6TcHt4mgR4f95Q= Xref: x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:699 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