Controlling the Flow
Often you want specified statements in your stored procedure to execute only if certain conditions are true. T-SQL contains several constructs that allow you to control the flow of your stored procedures. These include BEGIN...END, IF...ELSE, GOTO, RETURN, CASE, and WHILE. The sections that follow cover each of these constructs.
IF...ELSE
You use the IF...ELSE construct to make a decision within the stored procedure. This decision is generally based on parameters supplied to the stored procedure. The IF...ELSE construct works like this:
IF (SomeCondition) BEGIN --Execute multiple statements END
With this version of the IF...ELSE construct, certain statements execute only if the condition is true. No special statements execute ...
Get Alison Balter's Mastering Access 2002 Enterprise Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.