IIF Statement

  • I am trying to get an IIF statement to work. it is very simple:

    SELECT IIF( -1 < 1, 'TRUE', 'FALSE' ) AS Result

    and I get the output:

    Msg 102, Level 15, State 1, Line 2

    Incorrect syntax near '>'.

    is there something I am doing blaringly obviously incorrect.

  • What version of SQL are you working with? If 2005, that's why you're getting an error, IIF was added in SQL 2012.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • That might explain alot, I am using 2005!!

    thank you

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply