Question: I have the following sql comparison using `IIF` keyword

```
DECLARE @a int, @b int
SET @a = 10
SET @b = 20

BEGIN
   SELECT IIF( @a < @b, 'True', 'False') As Result
END

```

However, on execution it gives an error

```
Incorrect syntax near '<'

```

What is causing this?

Answer: 
As mentioned in comments, `IIF` is a new function in SQL Server 2012+, so you'll have to use a `CASE` statement instead:

```
DECLARE @a int, @b int
SET @a = 10
SET @b = 20

BEGIN
   SELECT CASE WHEN @a < @b THEN 'True' ELSE 'False' END As Result
END

```
IIF was used in VBA, but not available in SQL Server until the 2012 release. use the SELECT CASE statement instead.

```
DECLARE @a int, @b int
SET @a = 10
SET @b = 20

BEGIN
   SELECT CASE WHEN @a < @b THEN 'True' ELSE 'False' END As Result
END

```