How to write IF (expr1, expr2, expr3) in mssql

In my sql there is IF (expr1, expr2, expr3).

How to do it in MS SQL?

+5
source share
1 answer

You can use the CASE expression :

CASE WHEN expr1 THEN expr2 ELSE expr3 END

By the way, this syntax is not specific to SQL Server - it also works in MySQL and most other databases.

+10
source

All Articles