Testing value with IF in SQL Server

Viewed 56

My company has tasked me to convert my department's database from MySQL to SQL Server Express (2018, I believe) I have extensive experience in MySQL but this is the first time I've more than dabbled in SQL Server.

It appears that using IF to test a value may not be supported. In this typical code sample, the IF is part of a larger expression. If it's necessary to use CASE WHEN ELSE how do I embed that within a function?

In MySQL:

SET course_dir = kappa + IF(kappa > 90,-1,1) * kappa_rot
1 Answers

SQL Server is using IIF function. See details

syntax

IIF ( boolean_expression, true_value, false_value )  

your query

SET course_dir = kappa + IIF(kappa > 90,-1,1) * kappa_rot
Related