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.


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


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


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


IIF Function

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



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


Leave a Reply

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

You are commenting using your 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.

%d bloggers like this: