Specifies a compound statement.
BEGIN statement-list END
statement-list : sql-statement | variable-declaration | cursor-declaration | temporary-table-declaration
variable-declaration : See DECLARE statement.
cursor-declaration : See DECLARE CURSOR statement [ESQL] [SP].
temporary-table-declaration : See DECLARE LOCAL TEMPORARY TABLE statement.
statement-list A list of statements and declarations.
A BEGIN statement allows one or more SQL statements to be grouped together and treated as a unit, and starts with the keyword BEGIN and ends with the keyword END.
Error handling is different for Transact-SQL compound statements.
None.
SQL/2008 BEGIN, which identifies a compound statement, comprises part of optional SQL language feature P002 in SQL/2008.
The example below declares the following variables:
BEGIN DECLARE v1 INT = 5 DECLARE v2, v3 CHAR(10) = 'abc' // ... END