Microsoft SQL Server CHOOSE


Example

SQL Server 2012

Returns the item at the specified index from a list of values. If index exceeds the bounds of values then NULL is returned.

Parameters:

  1. index: integer, index to item in values. 1-based.
  2. values: any type, comma separated list
SELECT CHOOSE (1, 'apples', 'pears', 'oranges', 'bananas') AS chosen_result

chosen_result
-------------
apples