Database Reference
In-Depth Information
Chapter 7
Windows Azure SQL Database
Procedures and Functions
Objectives
◾
Learn programming extensions
◾
Create and use stored procedures, functions, and triggers
7.1 Introduction
Previously, you learned how to create and manage database objects and query information from
a database. You accomplish those tasks by executing SQL statements one at a time. Sometimes,
for more complicated management and query tasks, you may need to execute multiple SQL state-
ments together or run a group of SQL statements repeatedly. A group of SQL statements that can
be executed together is called an SQL procedure. he current standard ANSI SQL does not sup-
port procedural SQL programs. Many DBMS vendors provide their own versions of procedural
SQL to extend the standard ANSI SQL. Windows Azure SQL Database provides Transact-SQL
(T-SQL) as the extension of the standard ANSI SQL. In this chapter, you will learn about various
programming units such as stored procedures, user-deined functions, and triggers created with
procedural SQL.
7.2 SQL Programming Extensions
To meet the requirements of procedural programming, Transact-SQL allows us to declare vari-
ables, control the execution of code with low-control structures, and handle errors. Some of these
extensions will be discussed in this section. In later sections, these extensions will be used in vari-
ous SQL programs.