Results 1 to 3 of 3
  1. #1
    HardDisk Guest

    Question IIF statement and MSSQL 2008

    Hello everyone,

    I am new to MSSQL. I got my introduction in MSSQL 2012 but right now for my project i am working on MSSQL 2008. I am writing a small query but it is giving me an error. I hope one of you can point me to right direction, I am guessing this is not a valid function 2008 only 2010.

    SET @Var1 = @Var2 +
      IIF(@Var2, 'value when true', 'value when false')
    Needless to say @Var2 is a true false variable.
    I get
    HTML Code:
    IIF(...) is not a recognized built-in function name
    What can i use in place of iif ?

  2. #2
    FatBoy Guest


    IIF is not a valid function in 2008. It was introduced in 2012. You can use CASE in its place.

  3. #3
    Chand Guest


    Here you go HardDisk

    SET @Var1 = @Var2 + CASE
     WHEN @Var3
     THEN 'value1'
     ELSE 'value2'


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts