Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the CONCAT function in SQL Server 2008 R2?

I was looking for a CONCAT function in SQL Server 2008 R2. I found the link for this function. But when I use this function, it gives the following error:

Msg 195, Level 15, State 10, Line 7
'CONCAT' is not a recognized built-in function name.

Does the CONCAT function exists in SQL Server 2008 R2?

If not, how do I concatenate strings in SQL Server 2008 R2?

like image 990
Mitesh Budhabhatti Avatar asked May 11 '12 11:05

Mitesh Budhabhatti


People also ask

How do I concatenate in SQL Server 2008?

From SQL Server 2008 R2 version and below the "+" (plus sign) is an operator used in a string expression that concatenates two or more character or binary strings, columns, or a combination of strings and column names into one expression or into another column.

How concat function works in SQL?

CONCAT takes a variable number of string arguments and concatenates (or joins) them into a single string. It requires a minimum of two input values; otherwise, CONCAT will raise an error. CONCAT implicitly converts all arguments to string types before concatenation.


1 Answers

Just for completeness - in SQL 2008 you would use the plus + operator to perform string concatenation.

Take a look at the MSDN reference with sample code. Starting with SQL 2012, you may wish to use the new CONCAT function.

like image 171
Lynn Langit Avatar answered Oct 26 '22 15:10

Lynn Langit