Home > SQL Server > SQL SERVER 2012 – CONCAT() An Introduction to String Concatenation Function

SQL SERVER 2012 – CONCAT() An Introduction to String Concatenation Function


CONCAT() : It is a string concatenation function introduced in SQL SERVER 2012. It helps us to merge or concatenate two or more string values in to a single string value. We must provide at-least two string values to this function otherwise this function will raise an error. The length of the output string is determined by the function arguments.

Function argument type and output type and its length mapping

pic1If all the function arguments are null then CONCAT function returns a single byte empty string value.

Usage

CONCAT ( string value1, string value2 [, string value N ] )

Where N = 255, So, the total number of arguments to this function is 255.

Example

1. This is a simple example to show the use of CONCAT function

pic22. In this example we are going to use NULL value in the argument

pic3pic4We can also use other data typed arguments in this function argument. I hope you have understood the concept and the use of CONCAT string function.

Learn more about other new functions in SQL SERVER 2012 here.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: