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
|
No comments:
Post a Comment