Collection Contents Index HELP statement [ISQL] IF statement [T-SQL] pdf/chap9.pdf

Reference Manual
   CHAPTER 9. SQL Statements     

IF statement


Function 

Provide conditional execution of SQL statements.

Syntax 

IF search-condition THEN statement-list
... [ ELSEIF search-condition THEN statement-list ] ...
... [ ELSE statement-list ]
... END IF

Permissions 

None.

Side effects 

None.

See also 

BEGIN... END statement

Using Procedures, Triggers, and Batches

Description 

The IF statement is a control statement that allows you to conditionally execute the first list of SQL statements whose search-condition evaluates to TRUE. If no search-condition evaluates to TRUE, and an ELSE clause exists, the statement-list in the ELSE clause is executed.

Execution resumes at the first statement after the END IF.

IF statement is different from IF expression    
Do not confuse the syntax of the IF statement with that of the IF expression.

For information on the IF expression, see IF expressions.

Standards and compatibility 

Example 


Collection Contents Index HELP statement [ISQL] IF statement [T-SQL] pdf/chap9.pdf