RETURN Statement

Exits a function or procedure unconditionally, optionally providing a return value. Statements following RETURN are not executed.

Syntax

RETURN [ ( expression ) ]

Examples

Usage

If expression is supplied, the value of expression is returned as the value of the function or procedure.

Within a function, the expression should be of the same data type as the RETURN data type of the function.

RETURN is used in procedures for Transact-SQL-compatibility, and is used to return an integer error code.

Standards

  • SQL—ISO/ANSI SQL compliant.

  • Sybase—Transact-SQL procedures use the return statement to return an integer error code.

Permissions

None

Related reference
BEGIN … END Statement
CREATE PROCEDURE Statement