Microsoft SQL Server Logical Functions CHOOSE

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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


Got any Microsoft SQL Server Question?