How to concatenate strings in sql server | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF 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

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget