Create a stored procedure of Example complete statement: USE pubsIF EXISTS (SELECT name FROM sysobjects WHERE name = 'up_test' AND type = 'P') DROP PROCEDURE up_test GOcreate procedure up_test @out_val integer = 0 output - @ out_val integer output - ---- 1ASBEGIN - SET @ out_val = 0 ----- 2 IF (1 = 1)
----- 3
Set @ out_val = @ out_val 1 Return 9; End
The stored procedure is inquiry analysis: 1, simple call
EXEC UP_TEST 3 - Note: The output parameter is also transmitted to the output parameter, and the parameter is not given to the parameter when there is a given default value.
2, call and use the output parameters and return values during the stored procedure
Declare @ret_val int declare @output_val int exec @ RET_VAL = Up_test @ out_val = @ output_val output
----- 4
SELECT @ RET_VAL, @ output_val denotes: If it is only given a default value, the output parameter is not transmitted to the output, and there is no such as the storage process body.
Set @ out_val = 0 Explicit
Output parameters
Assignment statement (use
Set @ out_val = @ OUT_VAL 1
Can't
Then, the feedback value of the output parameter is NULL after executing the stored procedure.
. I have encountered this in the call to the C #, but also let me debug the process for a long time. Later, I saw NULL in the SQL Serve query analyzer.
Take the realistic trouble.