Search code examples
sql-server-2014iif

Error with IIF statement in SQL Server 2014


I am creating an SQL Server 2014 view in Management Studio which uses the IIF statement but I keep getting the error: An expression on non-boolean type specified in a context where a condition is expected.

I tried a new view with a super-simple IIF statement and it too failed.

This is the statement I am using to test: SELECT IIF('1=1', 'True', 'False') AS Expr1


Solution

  • SELECT IIF(1=1, 'True', 'False') AS Expr1
    

    '1=1' you had previously was not a boolean condition. Changed it to 1=1