i have following sql comparison using iif
keyword
declare @a int, @b int set @a = 10 set @b = 20 begin select iif( @a < @b, 'true', 'false') result end
however, on execution gives error
incorrect syntax near '<'
what causing this?
as mentioned in comments, iif
new function in sql server 2012+, you'll have use case
statement instead:
declare @a int, @b int set @a = 10 set @b = 20 begin select case when @a < @b 'true' else 'false' end result end
Comments
Post a Comment