Muistiinpano
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää kirjautua sisään tai vaihtaa hakemistoa.
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää vaihtaa hakemistoa.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
SQL analytics endpoint in Microsoft Fabric
Warehouse in Microsoft Fabric
SQL database in Microsoft Fabric
Encloses a series of Transact-SQL statements that will execute as a group. BEGIN...END blocks can be nested.
Transact-SQL syntax conventions
Syntax
BEGIN
{ sql_statement | statement_block }
END
Arguments
{ sql_statement| statement_block}
Is any valid Transact-SQL statement or statement grouping as defined with a statement block. To define a statement block (batch), use the control-of-flow language keywords BEGIN and END. Although all Transact-SQL statements are valid within a BEGIN...END block, certain Transact-SQL statements should not be grouped together within the same batch (statement block).
Result Types
Boolean
Examples: Azure Synapse Analytics
In the following example, BEGIN and END define a series of SQL statements that run together. If the BEGIN...END block are not included, the following example will be in a continuous loop.
-- Uses AdventureWorks
DECLARE @Iteration INTEGER = 0
WHILE @Iteration <10
BEGIN
SELECT FirstName, MiddleName
FROM dbo.DimCustomer WHERE LastName = 'Adams';
SET @Iteration += 1
END;