This is a new function introduced after SQL Server 2012. function is like the meaning of its name. It is null-worthy to handle an empty string. Of course, it can do more than just support for characters. It supports n column input, and the column type support is more complete. However, its principle is simply to convert the incoming data into a nvarchar type using the CONVERT function. Don't believe you send an XML or sql_variant type of data in, you will see an error immediately. The error prompt is:
257 Level - 3 * from to nvarcharisn't useCONVERT function to run this query.
At least my test results show that it is supported for int, FLOAT, DATETIME, nvarchar.
Test scripts
withT as (SELECT TOP Ten CAST(Num as INT) asINT_FLD,CAST(Num as NVARCHAR) asSTR_FLD,CAST(Num as FLOAT) asFLT_FLD,CAST(NULL as NVARCHAR) asNULL_FLD,CAST(Num as datetime) asdt_fld--CAST (Num as sql_variant) as VAR_FLD,--CAST (' <a>aa</a> ' as XML) as XML_FLD fromdbo. Numbers)SELECTCONCAT (INT_FLD,STR_FLD,FLT_FLD,NULL_FLD, DT_FLD) fromT
SQL Server->> concat functions