Transact-SQL is Microsoft’s and Sybase’s proprietary extension to the conventional SQL (structured query language). Transact-SQL is sometimes abbreviated as T-SQL. This enhancement brought procedural programming language functionalities, such as local variables, control-of-flow constructs, and additional functions for various needs.
The purpose of this two-part article is to give a brief overview on the usage of T-SQL. If you are already familiar with any SQL flavor, whether it's MySQL, Oracle, or perhaps SQL-92, that’s a huge benefit. However, throughout this article I will assume that you have at least some knowledge regarding relational databases.
We’re going to cover the following programming concepts:
Usage of variables (data types, etc.)
Conditional statements (IF…ELSE, BEGIN…END)
Usage of CASE command
Usage of WHILE loops
CONTINUE command
BREAK command
GOTO command
RETURN command
WAITFOR command
Usage of cursors
Usage of functions
Creating functions of your own