SQL Function required - Choose()

T

Terry

Is there a SQL Server equivalent to the Microsoft Access function
Choose ( position, value1, value2, ... value_n ) ? Or is it achieved by
onother method?
Regards
 
S

Sylvain Lafontaine

The Case statement offer a similar - but not identical - functionality.
There are two forms of it:

Select
Case Field1 When 1 then 'One' When 2 then 'Two' Else 'Don''t know' End as
No1,
Case When Field1 = 1 then 'One' When Field1 = 2 then 'Two' Else 'Don''t know
either' End as No2,
....

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain aei ca (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)
 
T

Terry

Hi Sylvain,
Thanks for the info. I guess the second example will do the trick.
Regards
Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top