Data Loader

Concatenating Strings in MS SQL Server with CONCAT function or + Operator and it's equivalent in MySQL

In MS SQL Server the CONCAT function is introduced in MS SQL Server 2012 edition only. In the prrior versions we have to use + operator to join strings.

Here is the syntax of MSSQL CONCAT function

CONCAT ( string_value1, string_value2 [, string_valueN ] )


Select concat('This ','is ','Testing');

This is Testing

Using + operator

select 'This ' + 'is '+'Testing';

This is Testing

MSSQL + concatenate operator


The equivalent function in MySQL is available with exact name i.e. CONCAT. Further more, MySQL also provides an extended function called CONCAT_WS. The CONCAT_WS function joins string with a separtor character.

Here are the examples

Select concat('This ','is ','Testing');

This is Testing


CONCAT_WS function concatenates strings with separator in between. The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated.




mysql>select concat(' ','This','is','Testing');

This is Testing

mysql>select CONCAT_WS(', ','Adam','Smith','Joseph');

Adam, Smith, Joseph




Back to Converting Functions from MSSQL to MySQL

The MSSQL to MySQL  converter will automatically convert the MSSQL functions to it's equivalent in MySQL while converting veiws.