Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SQL Server 2014 Development Essentials

You're reading from   SQL Server 2014 Development Essentials Design, implement, and deliver a successful database solution with Microsoft SQL Server 2014.

Arrow left icon
Product type Paperback
Published in Jul 2014
Publisher
ISBN-13 9781782172550
Length 214 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Basit A. Masood-Al-Farooq Basit A. Masood-Al-Farooq
Author Profile Icon Basit A. Masood-Al-Farooq
Basit A. Masood-Al-Farooq
Arrow right icon
View More author details
Toc

Table of Contents (8) Chapters Close

Preface 1. Microsoft SQL Server Database Design Principles FREE CHAPTER 2. Understanding DDL and DCL Statements in SQL Server 3. Data Retrieval Using Transact-SQL Statements 4. Data Modification with SQL Server Transact-SQL Statements 5. Understanding Advanced Database Programming Objects and Error Handling 6. Performance Basics Index

Control-of-flow keywords


Control-of-flow keywords help SQL Server determine when and how Transact-SQL statements should execute. With these keywords, you can add logic around and within Transact-SQL statements to control program execution. Control-of-flow keywords add greater flexibility in OLTP application design and help you write clever code. Control-of-flow keywords include BEGIN…END, IF…ELSE, CASE, WHILE, BREAK, CONTINUE, RETURN, GOTO, and WAITFOR.

BEGIN…END keywords

The BEGIN…END keywords identify a code block. We typically use them to group Transact-SQL statements. The BEGIN…END blocks can be nested. We also use BEGIN…END statements to identify a code block in an IF…ELSE clause, WHILE loop, and CASE element. The following is the basic syntax for the BEGIN…END keyword block:

BEGIN
     {
    sql_statement | statement_block
     }
END

The following is a basic example of BEGIN…END:

USE [AdventureWorks2012];
GO

BEGIN
    DECLARE @Today [datetime];
    SET @Today = CURRENT_TIMESTAMP;

   ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime