3

We have parameter direction as output in parameter binding and at the same time we do have result binding. So if we are having output variable or return type variable which will be available at output, so why do we need Result binding then.

Hadi
  • 36,233
  • 13
  • 65
  • 124
Kashish Aneja
  • 41
  • 1
  • 6

1 Answers1

1

ResultSets and output parameters are not the same, each one of them has it own use:

  • ResultSets are used to store a result of a Select query: It can be a one or more columns and it can be a single row or a full result set. ResultSets are retrieved as ADO RecordSets and can be stored within variables. In general a RecordSet can be consumed on time.

  • Output Parameters are used to store some values that can be set any part of the SQL command (not necessary at the end). Parameters have the same concept of a SQL stored procedure parameters. The value can be used several times.

You can have an Execute SQL Task with output parameters and a ResultSet.


Additional Information


Update 1 @ 2019-16-08

You can use the output parameter as input parameter in another stored procedure but you have to execute it in a separate Execute SQL Task.

If you need to execute both stored procedures within one Execute SQL Task, then you can use SQL variables as mentioned in the example below:

DECLARE @output VARCHAR(50)

EXEC proc1 @output OUTPUT

EXEC proc2 @output

Update 2 @ 2019-19-09

Recently I published a detailed article about this topic on SQL Shack, you can check it on:

Hadi
  • 36,233
  • 13
  • 65
  • 124
  • Thank you very much for the information. In case parameter binding, output parameter is just a name which will get value after the procedure gets executed and its value returned can be used as input variable for other procedures? – Kashish Aneja Aug 16 '19 at 02:16
  • @KashishAneja Recently I published a detailed article about this topic on SQL Shack, you can check it on the link i added to my answer – Hadi Sep 19 '19 at 19:32