Friday, February 14, 2020

'CONCAT' is not a recognized built-in function name

"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

Mixed Content: The page at xxx was loaded over HTTPS, but requested an insecure

 Mixed Content: The page at ' https ://www.test.com/signup.aspx' was loaded over HTTPS, but requested an insecure script ' http ...