Open links in new tab
  1. sql server - How do I perform an IF...THEN in an SQL SELECT?

    Sep 15, 2008 · From SQL Server 2012 you can use the IIF function for this. SELECT IIF(Obsolete = 'N' OR InStock = 'Y', 1, 0) AS Salable, * FROM Product This is effectively just a shorthand (albeit not standard SQL) way of writing CASE. I prefer the conciseness when compared with the expanded CASE version.

  2. sql - Using an IIF statement in a where clause - Stack Overflow

    Nov 24, 2017 · I am trying to add multiple criteria to a Where clause in SQL Server 2014 using the following code and I ...

  3. IIF statement in SQL Server 2005 - Stack Overflow

    Nov 6, 2013 · That IIF statement only exists in MDX - the query language for SQL Server Analysis Services - the datawarehousing side of SQL Server. Plain T-SQL does not have an IIF statement. The best you can do in T-SQL is use the CASE....

  4. sql - IIF(...) not a recognized built-in function - Stack Overflow

    Aug 20, 2012 · SQL Server 2012 introduces 14 new built-in functions. These functions ease the path of migration for information workers by emulating functionality that is found in the expression languages of many desktop applications. However these functions will also be useful to experienced users of SQL Server.... IIF (Transact SQL)

  5. SQL Server IIF vs CASE - Stack Overflow

    Apr 3, 2014 · IIF is the same as CASE WHEN <Condition> THEN <true part> ELSE <false part> END. The query plan will be the same. It is, perhaps, "syntactical sugar" as initially implemented. CASE is portable across all SQL platforms whereas IIF is SQL SERVER 2012+ specific.

  6. SQL Server 2008 IIF statement does not seem enabled

    IFF is available starting from SQL Server 2012. So use 'Case' instead. So use 'Case' instead. If you are looking for a more compact form (function instead of case) in SQL Server 2008 you can use:

  7. sql - How to use multiple conditions (With AND) in IIF expressions …

    You don't need an IIF() at all here. The comparisons return true or false anyway. Also, since this row visibility is on a group row, make sure you use the same aggregate function on the fields as you use in the fields in the row.

  8. sql server - Using IIF in SQL update statement - Stack Overflow

    Feb 15, 2013 · I've rewritten your statement using CASE (but I realize IIF works in 2012): UPDATE EMP SET fte_adj = CASE WHEN (FTE < 1 OR FTE IS NULL) AND [employment category] Like '*Full-Time*' THEN 1 ELSE CASE WHEN (FTE = 0 OR FTE IS NULL) AND [employment category] Like '*Part-Time*' THEN 0.25 ELSE CASE WHEN (SELECT COUNT(*) FROM SEC_EMP) = 0 THEN 1 ELSE FTE END END END

  9. sql server - Error when combining IIF and 'Is Null' - Stack Overflow

    Apr 24, 2018 · IIF (Transact-SQL) was introduced in SQL Server 2012. The problem is you're trying to use a function that doesn't exist, not that IS NULL is an issue. IIF is a shorthand way for writing a CASE expression. It evaluates the Boolean expression passed as the first argument, and then returns either of the other two arguments based on the result of ...

  10. sql server - IIF in Where Part on SQL Select - Stack Overflow

    Jul 10, 2019 · Incidentally, recent version of SQL Server offer row-level security, where tables can be automatically filtered by the engine based on conditions (for example, SESSION_CONTEXT). This is not always an appropriate alternative for custom application checks (which are more flexible) but can save on a lot of code when it is. –

Refresh