The topic describes the DF009 T-SQL code analysis rule.
BEST PRACTICE
The RETURN statement does not return any values.
The RETURN statement does not return the result code to indicate the result of the execution.
RETURN cannot return a null value when used within a stored procedure. If the procedure tries to return null, it will cause a warning and return a value of 0 instead.
It is possible to retrieve the return status value in subsequent Transact-SQL statements within the batch or procedure that executed the current procedure by running the following command - EXECUTE @return_status = <procedure_name>
.
CREATE OR ALTER PROCEDURE dbo.DemoProcedure
AS BEGIN
RETURN
END
GO
CREATE OR ALTER PROCEDURE dbo.DemoProcedure
AS BEGIN
RETURN 0
END
GO