Why is this throwing an error on the equal sign?
select IIF((SUBSTRING('A1234', 1, 1) = 'A'), TRUE, FALSE) as IsAustraliaUser
Error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '='.
IIF
is a SQL Server 2012 feature, you'll need to use CASE
SELECT CASE SUBSTRING('A1234', 1, 1)
WHEN 'A' THEN 'TRUE'
ELSE 'FALSE'
END
You should replace IIF with CASE, also TRUE and FALSE don't exists in SQL Server, you can use VARCHAR or BIT
select CASE WHEN SUBSTRING('A1234', 1, 1) = 'A' THEN 'TRUE' ELSE 'FALSE' END as IsAustraliaUser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With