IIF() function syntax with an example in SQL Server

    IIF() function syntax with an example in SQL Server


·        This function returns one of two values, depending on whether the Boolean expression evaluates to true or false.

·        IIF ()  is a shorthand way for writing a CASE statement. It evaluates the Boolean expression passed as the first argument, and then returns either of the other two arguments based on the result of the evaluation.

            Example:
            DECLARE @a int = 45;
            DECLARE @b int = 40;
            SELECT IIF (@a > @b, 'TRUE', ‘FALSE’)

            Result:
                        TRUE


If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar