DF009: The RETURN statement does not return any values.

Last modified: March 28, 2025

The topic describes the DF009 T-SQL code analysis rule.

Category

BEST PRACTICE

Message

The RETURN statement does not return any values.

Description

The RETURN statement does not return the result code to indicate the result of the execution.

Additional information

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>.

Noncompliant code example

CREATE OR ALTER PROCEDURE dbo.DemoProcedure
AS BEGIN
RETURN
END
GO

Compliant solution

CREATE OR ALTER PROCEDURE dbo.DemoProcedure
AS BEGIN
RETURN 0
END
GO