DF009: The RETURN statement does not return any values.
Last modified: May 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
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.