Choose and IIF Function in Sql Server

Choose function in SQL Server is used to get the item at the specified index from the list of available values. The index position starts with 1.

Syntax

Select choose(index,value1,value2,..)

1

If the mentioned index is greater or less than the specified values, It results null.

2

If we pass the float value in the index it will be converted to an integer, based on that the value will be selected.

3

IIF Function

If function returns the one of the two values, depending on the condition evaluates true or false.

Syntax


IIF(BOOLEAN CONDITION,TRUE_VALUE,FALSE_VALUE

The IIF function is like Ternary operator in a programming language with single condition.

4

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.