1

I need to retrieve the first result set from a stored procedure, this procedure returns tow result set And I need the first one only How Can I do it ??

for example : 

   -- the first result 

        -----------------------------------------
        | ID | Code | Name | Notes | .... | ... |
        -----------------------------------------
        |    |      |      |       |      |     |

   -- the second result
        -----------------
        | Date | Number |
        -----------------
        |      |        | 
Alaa
  • 545
  • 1
  • 5
  • 11
  • Check this thread: http://stackoverflow.com/questions/58940/access-to-result-sets-from-within-stored-procedures-transact-sql-sql-server – S.K Dec 06 '11 at 11:45

3 Answers3

0

Edit the stored procedure and delete/comment the second result.

aF.
  • 64,980
  • 43
  • 135
  • 198
0

If you are able to change the Stored Procedure code, you could add an Optional SQL Parameter, like:

@FirstOnly bit = 0

Then after the first SELECT statement, have the following query:

IF @FirstOnly=1
BEGIN
   RETURN
END
Curtis
  • 101,612
  • 66
  • 270
  • 352
  • You're write, But I don't want to alter the Procedure I'm looking for solution with out alter But if I didn't find I will use your solution thank you – Alaa Dec 06 '11 at 11:43
0

create a temporary table. execute the sql procedure and insert result into the temp table and select the first row. so you won't have to alter the procedure.

Saidur Rahman
  • 420
  • 2
  • 6
  • 19