How to concatenate strings in sql server - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial


How to concatenate strings in sql server

In this article I am going to explain how to concatenate strings in sql server.

Description:
Earlier we use concatenate strings in Sql server using + symbol. But now sql server introduces the CONCAT function in 2012.

Syntax of + symbol
Select column1+column2 from tablename

Syntax of concat function
Select concat(column1,column2)from tablename

 Example 1:
Select Name + Genre as [Movie Name & Genre] from Tb_Movie
SELECT CONCAT ( Name,Genre) from Tb_Movie

Output:
Movie Name & Genre
TalwarDrama

Example 2: add an empty space
Select Name +' '+ Genre as [Movie Name & Genre] from Tb_Movie
SELECT CONCAT (Name,' ',Genre) from Tb_Movie

Output:
Movie Name & Genre
Talwar Drama

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+
loading...


EmoticonEmoticon