CHOOSE – SQL Server Fuction

Leave a comment (0) Go to comments

SQL Server Denali CTP3 has introduces a new function CHOOSE() for selecting a specific value from a given options .

Choose () function is used to return any specific value from a given list, CHOOSE(), accepts two parameters, where the first parameter is

Index - Numeric expression that results in a value between 1 and the number of elements passed in the Choice argument and the second parameter is

Choice - parameter type array. You can supply either a single variable or an expression that evaluates to the Object data type, to a list of Object variables or expressions separated by commas, or to a single-dimensional array of Object elements.

How to use CHOOSE () function in SQL Server ?

CHOOSE   SQL Server Fuction SQL Server CHOOSE function How to use CHOOSE () function in SQL Server

In above example, the first parameter specifies the index (which value (index) to be picked up), Index specifies the location / sequence, which should be picked up from the second parameter, string array type.

Select CHOOSE (3, ‘A’,’B’,’C’,’D’,’E’) as Alphabets, here 3 specifies that pick the third (3) value from the given array, in this case the value is ‘C’ as index starts from 1.

EOF - CHOOSE – SQL Server Fuction, SQL Server 2012 , 2008 R2 , 2008 , 2005 , 2000

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.