T-SQL 101: 99 Applying conditional logic with IF
In general, we try to avoid procedural logic when writing T-SQL. However, it is possible.
The most basic procedural statement is the IF statement. It allows us to apply basic conditional logic. Instead of keywords like CASE that allow you to apply logic to determine values, the IF statement allows you to decide which statements are executed.
IF @Value > 10 PRINT 'Large';
The condition can also include other clauses linked with AND and OR:
2025-01-26