case expression

Using case expression simplifies standard SQL expressions by allowing a when...then construct instead of an if...else construct. A case expression is more concise than an if...else statement and Adaptive Server’s response time is faster, since the optimizer processes fewer lines of SQL code. Also, queries written using case expressions are often easier to read and understand than those written in standard SQL. Because of the concise nature of case expressions, they are allowed anywhere value expressions are used.

A case expression is written using the following syntax:

case
 	[when search_condition1 then result1]
 	[when search_conditionn then resultn] 
end

For more information about the syntax of case expressions, see the Adaptive Server Reference Manual.

For more information and examples of case expressions, see the Transact-SQL User’s Guide.