IIF() function syntax with an example in SQL
Server
Introduction:
In my previous posts we have seen what is Transact-Sql in sql server and What are new top features of T-Sql in server. This is one of the best sql server interview Questions and answers. Watch more ASP.NET, C#.NET, Jquery, Sql Server, HTML5, HTML, CSS, JQUERY UI Interview questions from here.
Description:
·
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.
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.