CONCAT() function advantages
Why should you use the new CONCAT() function? 2 good reasons:
- When using the CONCAT() function, non string datatype arguments can be included and are implicitly converted to a string datatype. Using the traditional “+” to concatenate fields, all of the fields concatenated needed to be of the same data type. Using the concatenate function reduces coding time as there is no need to convert datatypes.
- The CONCAT() function automatically handles NULL values. If a concatenated field contains NULL, the function substitutes and empty string of type varchar (1).
The CONCAT function was introduced in SQL Server 2012.