Thursday, October 4, 2012

How to concatenate strings in sql server 2012

In previous versions there is no direct function to make this one.If we want concatenate two strings we have to use '+' symbol .
But in the latest version of sql server2012 introduce a new string function "CONCAT()" ,which is used to concatenate the strings.Let me explain one example for how to use and execute this function in sql server 2012.
Here i have table with three five columns(id,name,sal,surname,add).Now i want to concatenate the name and surname when executes the select query from emp table

select id,CONCAT(name,surname) as FullName from employee

1 comment:

LA7 said...

Handy! Looks so much cleaner, especially where there are more than four or five fields being concatenated.

Bel