Description
Use this statement to control conditional execution of a SQL statement, as an alternative to the Watcom-SQL IF statement.
Syntax
IF expression
statement
[ ELSE
[ IF expression ]
statement ]
Usage
The Transact-SQL IF conditional and the ELSE conditional each control the execution of only a single SQL statement or compound statement (between the keywords BEGIN and END).
In comparison to the Watcom-SQL IF statement, there is no THEN in the Transact-SQL IF statement. The Transact-SQL version also has no ELSEIF or END IF keywords.
예)
IF @Argument = 1
BEGIN
SELECT '1'
SELECT '2'
END
Posted by 망고

