Thursday 17 November 2011

Introduction to New CONCAT() string Function in SQL Server CTP3 2012.

CONCAT()-Is introduced in Denali 2012, which can be used to concatenate two or more strings. This function requires 2 to 254 arguments.


let's check with following demo example.
--native method
select 'sql' + 'server'+ 'Denali'
--New Method
select concat('sql' ,'server',  'Denali')


Now we create test table to check how concat function works.


create table test12
(
id int,
name varchar(10),
city varchar(10)
)
insert into test12
select 1,null,'anand'


--native method
select (name+city) from test12
select (isnull(name,'')+city) from test12


--New Method
select concat(name,city) from test12


For more details go to CONCAT Function

No comments:

Post a Comment