Microsoft SQL Server Simple CASE statement


Example

In a simple case statement, one value or variable is checked against multiple possible answers. The code below is an example of a simple case statement:

SELECT CASE DATEPART(WEEKDAY, GETDATE())
    WHEN 1 THEN 'Sunday'
    WHEN 2 THEN 'Monday' 
    WHEN 3 THEN 'Tuesday' 
    WHEN 4 THEN 'Wednesday' 
    WHEN 5 THEN 'Thursday' 
    WHEN 6 THEN 'Friday' 
    WHEN 7 THEN 'Saturday' 
END