Return statement : Return « Transact SQL « SQL Server / T-SQL Tutorial






8>    Create PROC spTestReturns
9>    AS
10>       DECLARE @MyMessage        varchar(50)
11>       DECLARE @MyOtherMessage   varchar(50)
12>
13>       SELECT @MyMessage = 'Hi, '
14>       PRINT @MyMessage
15>       RETURN 100
16>       SELECT @MyOtherMessage = 'Sorry'
17>      PRINT @MyOtherMessage
18>    RETURN
19>    GO
1>
2>    drop PROC spTestReturns;
3>    GO
1>
2>








20.22.Return
20.22.1.RETURN is used to exit the current Transact-SQL batch, query, or stored procedure immediately.
20.22.2.RETURN also allows for an optional integer expression:
20.22.3.How to Use RETURN
20.22.4.Return statement
20.22.5.Return a table from a function
20.22.6.RETURNS a TABLE with structure
20.22.7.Assign returned value from a function to a declared variable