laika222
11/2/2017 - 2:47 AM

IF ELSE, Branching

-- IF...ELSE - uses a predicate to determine the flow of the code. The code in the IF block is executed if the predicate evaluates to TRUE, the code in the ELSE block is executed if the predicate evalues to be FALSE or UNKONWN. BEGIN and END are used around the block if there are more than one branch.

IF @color IS NULL
	SELECT * FROM Production.Product;
ELSE
	SELECT * FROM Prodction.Product
	WHERE COLOR = @color