Access to Result sets from within Stored procedures Transact-SQL SQL Server

前端 未结 7 1183
栀梦
栀梦 2020-11-27 17:59

I\'m using SQL Server 2005, and I would like to know how to access different result sets from within transact-sql. The following stored procedure returns two result sets, ho

7条回答
  •  旧巷少年郎
    2020-11-27 18:17

    The short answer is: you can't do it.

    From T-SQL there is no way to access multiple results of a nested stored procedure call, without changing the stored procedure as others have suggested.

    To be complete, if the procedure were returning a single result, you could insert it into a temp table or table variable with the following syntax:

    INSERT INTO #Table (...columns...)
    EXEC MySproc ...parameters...
    

    You can use the same syntax for a procedure that returns multiple results, but it will only process the first result, the rest will be discarded.

提交回复
热议问题