home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 17,518 of 19,505   
   Erland Sommarskog to HumanJHawkins   
   Re: Execute Multiple SPs From Another SP   
   01 Jun 09 21:47:00   
   
   7bc21580   
   From: esquel@sommarskog.se   
      
   HumanJHawkins (JHawkins@Locutius.Com) writes:   
   > I have two simple SPs. Each does something in a table, and then   
   > returns the number of rows that they acted on.   
   >   
   > I want to write an SP to run both of them. I have tried the following:   
   >   
   > EXEC SP1;   
   > EXEC SP2;   
   >   
   > But I only get the result for the first one. I'm not really sure if   
   > the second even ran.   
   >   
   > I also tried variations on the following, but only got syntax errors:   
   > SELECT (EXEC SP1) AS Count1, (EXEC SP2) AS Count2   
   >   
   > This has to be a common issue with a simple solution. But I can't find   
   > it. THanks in advance for any help.   
      
   It sounds as if you call your procedure from an application. If you   
   were to call your procedure from Mgmt Studio, you would see two result   
   sets. From application code, you may have to use some extra method to   
   proceed to the next result set. But since I don't know which API you   
   are using, I can't tell how to do it.   
      
   If all the procedures return is a single count value, it would probably   
   be better to return these as output parameters instead.   
      
   --   
   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   
   SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca