title: "BREAK (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/15/2017" ms.prod: sql ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw" ms.reviewer: "" ms.suite: "sql" ms.technology: t-sql ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords:
- "BREAK"
- "BREAK_TSQL" dev_langs:
- "TSQL" helpviewer_keywords:
- "exiting innermost loop [SQL Server]"
- "END keyword"
- "ignored statements"
- "BREAK keyword" ms.assetid: 67c30b8d-3f15-41ad-b9a9-a4ced3b2af9f caps.latest.revision: 34 author: "douglaslMS" ms.author: "douglasl" manager: craigg monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017"
[!INCLUDEtsql-appliesto-ss2008-all-md]
Exits the innermost loop in a WHILE statement or an IF…ELSE statement inside a WHILE loop. Any statements appearing after the END keyword, marking the end of the loop, are executed. BREAK is frequently, but not always, started by an IF test.
-- Uses AdventureWorks
WHILE ((SELECT AVG(ListPrice) FROM dbo.DimProduct) < $300)
BEGIN
UPDATE DimProduct
SET ListPrice = ListPrice * 2;
IF ((SELECT MAX(ListPrice) FROM dbo.DimProduct) > $500)
BREAK;
END
Control-of-Flow Language (Transact-SQL)
WHILE (Transact-SQL)
IF...ELSE (Transact-SQL)