O'Reilly logo

Alison Balter's Mastering Access 2002 Enterprise Development by Alison Balter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required