Pages

Thursday, September 3, 2009

An Output Parameter of a SP can be also used as input parameter

Did you know that you can pass a value to a stored procedure
also using an output parameter of the SP.

For example, lets create a SP with one output parameter
and pass a value to it when we call to the SP.

CREATE PROCEDURE usp_Test
(
@ID INT OUTPUT
)
AS
SET @ID=@ID+1
GO

DECLARE @OutputParam INT
SET @OutputParam=2
EXEC usp_Test @ID=@OutputParam OUTPUT
SELECT @OutputParam AS OutputParam

OutputParam

--------------
3

Also an output parameter can have a default value as regular input parameter.

No comments:

Post a Comment