Control-of-Flow Language

Transact-SQL provides control-of-flow language that you can use as part of any SQL statement or batch.

These constructs are available: You can define local variables with declare and assigned values. A number of predefined global variables are supplied by the system.

Transact-SQL also supports case expressions, which include the keywords case, when, then, coalesce, and nullif. case expressions replace the if statements of standard SQL. case expressions are allowed anywhere a value expression is used.