RETURN (TSQL Statement)

Exits unconditionally from the batch.

Syntax

RETURN [integer_expression] 

Arguments

integer_expression
optional argument. It is the value to return to the caller, of type int.

Return Types

Returns an int.

Remarks

If the argument is omitted, this statement returns 0.

Examples

DECLARE @i INT = 0;

WHILE @i < 100
  BEGIN
  PRINT @i;
  IF @i = 3
    RETURN -1;

  SET @i += 1;
  END

The result is:

0
1
2
3

and the RSQL Client rcli displays the return code -1.