Wednesday, February 28, 2007

SQL Conditional Logic

Here's my preferable way to do if else statements in T-SQL. The syntax is pretty simple.

select
case when conditional
then 'true case'
else 'false case'
end
as conditionalValue


Of course the comparisson opporators are <, =, <=, >, <>, >=, IS NULL, and IS NOT NULL.

Enjoy..

No comments: