The CONCAT function joins two or more string values together.
CONCAT converts all arguments to string types before concatenation.
CONCAT converts any NULL argument to an empty string.
This example joins three string values into a single string.
SELECT CONCAT('Lars',' ','Anderson') AS Name
| Name |
|---|
| Lars Anderson |
CONCAT takes two or more arguments.
The return value is either VARCHAR or NVARCHAR depending on the input types.
Syntax for the CONCAT function.
CONCAT (value1, value2, ...., valueN)
values -- required. Two or more parameters that can be converted to string.
| CUSTOMER |
|---|
| Id |
| FirstName |
| LastName |
| City |
| Country |
| Phone |
SELECT CONCAT(FirstName, ' ', LastName) AS Name,
City, Country
FROM Customer
| Name | City | Country |
|---|---|---|
| Maria Anders | Berlin | Germany |
| Ana Trujillo | México D.F. | Mexico |
| Antonio Moreno | México D.F. | Mexico |
| Thomas Hardy | London | UK |
| Christina Berglund | Luleå | Sweden |
![]() |
||
SELECT OrderNumber, ProductName,
CONCAT(I.Quantity, ' x $', NULL,
I.UnitPrice, ' = $',
I.UnitPrice * I.Quantity) AS Calculation
FROM OrderItem I
JOIN [Order] O ON O.Id = I.OrderId
JOIN Customer C ON C.Id = O.CustomerId
JOIN Product P ON P.Id = I.ProductId
WHERE OrderNumber = '542382'
| OrderNumber | ProductName | Calculation |
|---|---|---|
| 542382 | Sir Rodney's Marmalade | 40 x $64.80 = $2592.00 |
| 542382 | Geitost | 25 x $2.00 = $50.00 |
| 542382 | Camembert Pierrot | 40 x $27.20 = $1088.00 |