I'm new to SQL Server. Currently I'm working on an existing source code and I have some unclear point the stored procedure
For examples:
My_Stored_Procedure_1
CREATE PROC [dbo].[My_Stored_Procedure_1]
@ID INT,
@DATE DATETIME
AS
BEGIN
UPDATE query...
PRINT 'ID is ' + CAST(@ID AS VARCHAR(10))
END
My_Stored_Procedure_2
CREATE PROC [dbo].[My_Stored_Procedure_2]
@RESULT INT
AS
BEGIN
EXEC @RESULT = My_Stored_Procedure_1 // Unclear point
END
My question is that, I don't see any return value from the My_Stored_Procedure_1
, so what will be returned to @RESULT
variable? Maybe a default returned value of the executed stored procedure?
Thank you very much.
@Result will have default value that was passed while executing the Stored Procedure My_Stored_Procedure_2.
The statement EXEC @RESULT = My_Stored_Procedure_1
will execute with error and terminate the execution of My_Stored_Procedure_2 because you have not passing two input parameter to My_Stored_Procedure_1 sp while calling this.