Programming in MS SQL Server 2012 |
Begin ... EndBegin ... End is encloses a series of Transact-SQL statements so that a group of Transact-SQL statements can be executed. BEGIN and END are control-of-flow language keywords. Syntax -- Syntax --
BEGIN { sql_statement | statement_block } END sql_statement | statement_block sql_statement | statement_block is any valid Transact-SQL statement or statement grouping as defined by using a statement block. The following example describes a BEGIN ... END statement -- Example 83 --
SELECT * FROM EMP WHERE Emp_Code = 501
BEGIN TRANSACTION MyTransaction
USE EBusiness GO
BEGIN UPDATE EMP SET Emp_Name = 'TEST Employee 501' WHERE Emp_Code = 501
COMMIT TRANSACTION MyTransaction END
SELECT * FROM EMP WHERE Emp_Code = 501 Query Output Screen |
* * * * *