New function in DENALI SQL SERVER 2012 (CHOOSE)

Hello friends,

This is another post related to new functions in DENALI (SQL SERVER 2012).

So today I am going to discuss “CHOOSE” functions .By the name it is clear that it will choose value.

In a simple sentence you can say it array which give value according to index parameter.

Its syntax is very simple.


Below is example.


In the example we are passing month value in CHOOSE function and according to value it provide corresponding string value of month.


DECLARE @tblFriends AS TABLE (Prefix VARCHAR(10) ,
Fname VARCHAR(200),
LName VARCHAR(100),

INSERT INTO @tblFriends(Prefix,Fname,LName,DOB) VALUES('DR','Ravindra','Verma','1/1/1981')
INSERT INTO @tblFriends(Prefix,Fname,LName,DOB) VALUES('Mr','Rajul','Verma','3/3/1981')
INSERT INTO @tblFriends(Prefix,Fname,LName,DOB) VALUES('Sir','Suyash','Kokje','4/4/1981')
INSERT INTO @tblFriends(Prefix,Fname,LName,DOB) VALUES('Sardar','Ravindra','Dhariwal','2/2/1981')
INSERT INTO @tblFriends(Prefix,Fname,LName,DOB) VALUES('Pandit','Shyam','Purohit','5/5/1981')
INSERT INTO @tblFriends(Fname,LName,DOB) VALUES('Shrikant','Yadav','6/6/1981')
INSERT INTO @tblFriends(Fname,LName,DOB) VALUES('Sawan','Gupta','7/7/1981')
INSERT INTO @tblFriends(Fname,LName,DOB) VALUES('Pankaj','Tomar','8/8/1981')
INSERT INTO @tblFriends(Fname,LName,DOB) VALUES('Vaibhav','Joshi','9/9/1981')
INSERT INTO @tblFriends(Fname,LName,DOB) VALUES('Vikram','Chouhan','10/10/1981')
INSERT INTO @tblFriends(Fname,LName,DOB) VALUES('Subhash','Patidar','11/11/1981')
INSERT INTO @tblFriends(Fname,LName,DOB) VALUES('Vinay','Karma','12/12/1981')

SELECT CONCAT(Prefix,' ' ,FName, ' ',LName) AS ConcatName,
FROM @tblFriends

so when you execute this script you will get following result.

I hope you enjoyed learning this.

DR Ravindra Verma JAN
Mr Rajul Verma MAR
Sir Suyash Kokje APR
Sardar Ravindra Dhariwal FEB
Pandit Shyam Purohit MAY
Shrikant Yadav JUN
Sawan Gupta JUL
Pankaj Tomar AUG
Vaibhav Joshi SEP
Vikram Chouhan OCT
Subhash Patidar NOV
Vinay Karma DEC

You can view previous post related with this at


Rajat Jaiswal





Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s