Reputation: 13
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
Upvotes: 0
Views: 1346
Reputation: 1069
What it means is that the first parameter must return a true or false condition. Therefore, evaluating two integers will produce that. What you currently had was just a string
SELECT IIF(1=1, 'True', 'False') AS Expr1
Can do '1' = '1' as well
Upvotes: 0
Reputation: 49260
SELECT IIF(1=1, 'True', 'False') AS Expr1
'1=1'
you had previously was not a boolean
condition. Changed it to 1=1
Upvotes: 1