Given a stored procedure in SQL Server which has multiple select
statements, is there a way to work with those results separately while calling the procedure?>
While this does not appear to be supported natively in T-SQL, if using a CLR Stored Procedure is an option for you, then you should be able to create a Stored Procedure in your preferred .Net language that uses the SqlDataReader.NextResult()
method to advance to the desired result set and then send the SqlDataReader back via the SqlPipe.Send(SqlDataReader)
method. You would just need to pass in the SQL to execute and the desired result set as parameters to this proc.
This would allow you to work with the proc as is, without modifying it to send back all or only one result set.