Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

CHOOSE() function to choose a value from list of values - New addition in Denali CTP3

Jul 16 2011 12:13AM by Ramireddy   

SQL Server added another function CHOOSE(). which returns a value from the list of given values based on a given position. Suppose, below query will give output "Two".

SELECT CHOOSE(2,'One','Two','Three','Four')   

You can specify constants or variables or expressions as arguments. However, we can't give queries as arguments. Below query will returns error.

declare @t table(ID int,GrpID int)
insert into @t values (10,1),(15,1),(20,2),(12,1),(25,2)
select choose((select GrpID from @t where ID = 10),'one','two','three')

Solution is, create a variable and assign the query result to the variable and use that variable in choose() function.

declare @t table(ID int,GrpID int)
insert into @t values (10,1),(15,1),(20,2),(12,1),(25,2)
declare @GrpID int = (select GrpID from @t where ID = 10)
select choose(@GrpID,'one','two','three')
Read More..   [0 clicks]

Published under: SQL Server Tips ·  ·  ·  · 


Ramireddy
2 · 41% · 12972
6
 
0
Knew
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

Your Comment


Sign Up or Login to post a comment.

"CHOOSE() function to choose a value from list of values - New addition in Denali CTP3" rated 5 out of 5 by 6 readers
CHOOSE() function to choose a value from list of values - New addition in Denali CTP3 , 5.0 out of 5 based on 6 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]