How to use IIF() in SQL Server ?

Leave a comment (0) Go to comments

SQL Server Denali CTP3 has introduces a new function IIF() to evaluates specified expression and returns specified true/false values.

IIF(), is kind of shorthand way of writing a CASE expression where we can expect only two result either true or false. This function is same as available in other languages.

IIF(), accepts three parameters,

  1. First Parameter is condition, which you want to evaluate,
  2. Value which will be returned, if condition returns true
  3. Value which will be returned, if condition returns fale

How to use IIF() function in SQL Server ?

In the following example, we are testing whether 1 < 0 or not. As this condition is false IIF() will return the value specified in third parameter. If would have tested 1 > 0  then we will get a value specified as a second parameter as conditioned returns true.

How to use IIF() in SQL Server ? State: 2 Msg 125 Level 15 State 2 Line 6 Case expressions may only be nested to level 10 Msg 125 Line 6 Level 15 IIF fuction SQL Server denali CTP3 IIF fuction SQL Server 2011 2012 IIF () SQL Server IFF fuction SQL Server denali CTP3 IFF fuction SQL Server 2011 2012 IFF () SQL Server Conditional Operator Logical Function IIF() Case expressions may only be nested to level 10

HOW IIF () uses NULL?

How to use IIF() in SQL Server ? State: 2 Msg 125 Level 15 State 2 Line 6 Case expressions may only be nested to level 10 Msg 125 Line 6 Level 15 IIF fuction SQL Server denali CTP3 IIF fuction SQL Server 2011 2012 IIF () SQL Server IFF fuction SQL Server denali CTP3 IFF fuction SQL Server 2011 2012 IFF () SQL Server Conditional Operator Logical Function IIF() Case expressions may only be nested to level 10


IIF can return NULL as return value.

Note: IIF() is translated into CASE expression, and thus it can be nested up to only 10 levels.

EOF - How to use IIF() in SQL Server ?, SQL Server 2012 , 2008 R2 , 2008 , 2005 , 2000

Leave a Reply

Your email address will not be published. Required fields are marked *


*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.