CHOOSE() fucntion returns the value at the specified index position from the list. It is intriduced in SQL Server 2012.
syntax
CHOOSE ( index, Val1, Val2[, ...., Val
n ])
It allows up to the maximum of 254 list of values(i.e. 254 arguments for listing values ) and 1 argument for specifying index position
Sample DECLARE @Index INT = 2 -- 1= dev; 2 = Test; 3= QA; 4= Prod
,@DevPath VARCHAR(1000) = 'http://www.dev_geniiius.com'
,@TestPath VARCHAR(1000) = 'http://www.Test_geniiius.com'
,@QAPath VARCHAR(1000) = 'http://www.QA_geniiius.com'
,@PRODPath VARCHAR(1000) = 'http://www.PROD_geniiius.com'
SELECT CHOOSE( 2, @DevPath, @TestPath, @QAPath, @PRODPath ) as TheRealDeal
Output:
TheRealDeal
http://www.Test_geniiius.com