Handling CASE Expressions in SQL Server without Using OR

It seems that incorporating the OR operator directly in a CASE expression’s WHEN clause in SQL Server is not permitted, which can be challenging when trying to match multiple conditions. I need an alternative method to compare a column’s value against several possibilities without using OR. Below is an adjusted SQL example that handles multiple matching values in a cleaner way:

CASE WHEN sampleColumn IN (22978, 23218, 23219) 
     THEN 'Configuration A'
     ELSE 'Configuration B'
END AS system_configuration

This revised approach uses the IN operator to check several values, making the query more concise and compliant with SQL Server syntax.

An alternative approach worth considering is to use a subquery or a temporary table containing the set of values you want to match against. From my experience, this method not only improves readability but also facilitates future modifications. By joining your main query with this derived result set, you can dynamically select the corresponding configuration without embedding multiple conditions within a CASE expression. This technique proves particularly effective in scenarios with extended sets of matching values requiring frequent updates.