"CONCAT"
was introduced in SQL Server 2012; there is no way to make it work in SQL Server 2008 R2.use the ODBC CONCAT function like this:
SELECT {fn CONCAT('foo ', 'test') }
The problem with this is that this function only allows you two parameters at a time. So unless you want to use more than two like this:
SELECT {fn CONCAT('foo ', {fn CONCAT('test ', 'buddy')}) }
just use the '+' operator.
Syntax:
select
RTRIM(LTRIM(
CONCAT(
COALESCE(c.Prefix + ' ', '')
, COALESCE(c.FirstName + ' ', '')
, COALESCE(c.MiddleName + ' ', '')
, COALESCE(c.LastName + ' ', '')
, COALESCE(c.Suffix,+ ' ', '')
)
)) as CustomerName from TableName
-- To Check SQL Server version
--SELECT @@VERSION;
-- Microsoft SQL Server 2017
No comments:
Post a Comment