New SQL Server 2012 Function — CONCAT()

When you work with string concatenation in SQL Server  before SQL Server 2012,  you need to explicitly handle NULL values and other datatype to string type in order to return a concatenated string. If you don’t replace NULL with an empty string, the result of the concatenation will be NULL.

Here comes a new function in SQL Server 2012: CONCAT(). It simplifies the concatenation operation.

The syntax is: CONCAT ( string_value1, string_value2 [, string_valueN ] )

You need to have minimum of two input values to use this fuinction. All input values inside the sunction are implicitly converted to string types first and then concatenated to return a string value. If there is any NULL value as input string, it will be converted as varchar(1) empty string  implicitly.

You can read more from MSDN for this function:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s