Encloses a series of SQL statements so that control-of-flow language, such as if...else, can affect the performance of the entire group.
begin statement block end
if (select avg (price) from titles) < $15 begin update titles set price = price * $2 select title, price from titles where price > $28 end
create trigger deltitle on titles for delete as if (select count (*) from deleted, salesdetail where salesdetail.title_id = deleted.title_id) > 0 begin rollback transaction print "You can’t delete a title with sales." end else print "Deletion successful--no sales for this title."
begin...end blocks can nest within other begin...end blocks.
ANSI SQL – Compliance level: Transact-SQL extension.
No permission is required to use begin...end.