IIF Function

  • I have Access SQL code that I need to transfer to SQL Server SQL. I have many IIF functions in the SQL. Can we use the IIF function from Access in SQL Server or do we have to use CASE or regular IF statements?

    Thanks

  • There isn't any IIF in SQL Server. Use the CASE statement.

    -SQLBill

  • I have always found that for complex IIF(expression,truepart,falsepart) statements there is no real alternative but to convert to CASE WHEN expression THEN truepart ELSE falsepart END. However SQL Server does have some functions that work for simple criteria, e.g. ISNULL(expression, replacement), which is the equivalent of Access' Nz() with two argumants and NULLIF(expression1,expression2) which returns NULL if expression1 = expression2.

  • Similar reply like other did - Use CASE statement. Check out the link - Vyas has a nice example.

    http://vyaskn.tripod.com/programming_faq.htm#q2

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

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