CHOOSE function with different data types data as list of values + SQL Server 2012

Posted by Bandi under Sql Server category on | Points: 40 | Views : 215
CHOOSE function returns the data type with the highest precedence from the set of types passed to the function.


SELECT CHOOSE(4, 1, 'Option1', GETDATE(), 3.14159, PI() ) AS [FourthValueAsOutput]

1900-01-04 03:23:53.373

Here, the fourth value in the list is 3.14159 ; but the result is a DATETIME value.
The highest precedence from list of above values in the CHOOSE is DATETIME' So the result 3.14159 is added to default datetime value '1900-01-01'

Comments or Responses

Login to post response