Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What is the use of sql iif statement in sql server 2012?


Asked by Vivian Meyers on Dec 12, 2021 SQL



Overview of SQL IIF Statement. June 12, 2019 by Rajendra Gupta. SQL Server 2012 introduced a new built-in logical function SQL IIF. It is a shorthand form of writing CASE statement logic or IF-ELSE logic. We explored Case Statement in SQL in my earlier article.
Just so,
SQL Else If. The SQL Else If statement is very useful to check multiple conditions at once. It is an extension to the If then Else (which we discussed in the earlier post). If Else statement will only execute the statements when the given condition is either true or False but in real world, we may have to check more than two conditions.
Accordingly, Functions are used in SQL as they are in many languages to manipulate, modify, format, convert and calculate with data. Officially, Oracle functions are accepting arguments and returning values. Functions can be the kind that operates on each row individually, effecting the display of data for that row or functions that operate on groups.
Next,
In the introduction of SQL IIF Statement, we mentioned that it is a shorthand form of writing CASE statement logic or IF-ELSE logic. Yes, it is true. Internally SQL Server converts the statement into the CASE statement and executes. We can check it using the actual execution plan of a query.
And,
SQL IIF Statement overview 1 Boolean_expression: The first parameter in SQL IIF statement is a boolean expression. ... 2 True_Value: If the boolean_expression is TRUE, it returns value specified in the true_value parameter 3 False_Value: If the boolean_expression is FALSE, it returns value specified in the false_value parameter