Logical function – Choose – SQL Server 2012


CHOOSE function is the logical function. It is similar to SWITCH function in .NET. Choose function will return the item at the specified index from the list of values .

-- below query will return "SQLDBPool-2"as output
Select CHOOSE(2,'SQLDBPool','SQLDBPool-2','SQLDBPool-3')

-- below query will return "Thursday"as output
DECLARE @day as int
set @day = 5
SELECT Choose(@day,'Sunday','Monday', 'Tuesday', 'Wednesday','Thursday','Friday','Saturday')
Advertisements

Thanks for the comment, will get back to you soon... Jugal Shah

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s