SQL Server users use Transact-SQL programming to create sets of statements for ad-hoc execution. The aim of the Transact-SQL programming is to carry out its transformation objectives by using: Command statements, Variables, and Control-of-flow statements. In this context, a command statement is any executable statement. This includes Transact-SQL commands, stored procedures and functions. Stored procedures and functions are both command statements and contain command statements. Variables provide temporary storage. You can define local variables and global variables. As compared to global variables, local variables have a more limited scope (availability). Each variable is defined with a data type to specify the type of data it can store. Control-of-flow statements, as the name implies, control program execution. Use control flow statements to manage how your statements execute, such as deciding which statements are executed based on values and conditions (if this is true, then do that) current. You can also create loops, which are statements that are executed repeatedly.
Checkout the part-1 of this three part article series here, in which you will learn how to use scripts and batches, and basics of Transact-SQL variables.
This article is published on SSWUG.org.