Concatenation

You can concatenate binary or character expressions—combine two or more character or binary strings, character or binary data, or a combination of them—with the + string concatenation operator. The maximum length of a concatenated string is 16384 bytes.

When you concatenate character strings, enclose each character expression in single or double quotes.

The concatenation syntax is:

select (expression + expression [+ expression]...) 

Here is how to combine two character strings:

select ("abc" + "def") 
------- 
abcdef 
 
(1 row affected) 

This query displays California authors’ names under the column heading Moniker in last name-first name order, with a comma and space after the last name:

select Moniker = (au_lname + ", " + au_fname) 
from authors 
where state = "CA" 
Moniker 
------------------------------------------------- 
White, Johnson 
Green, Marjorie 
Carson, Cheryl 
O’Leary, Michael 
Straight, Dick 
Bennet, Abraham 
Dull, Ann 
Gringlesby, Burt 
Locksley, Chastity 
Yokomoto, Akiko 
Stringer, Dirk 
MacFeather, Stearns 
Karsen, Livia 
Hunter, Sheryl 
McBadden, Heather 
 
(15 rows affected) 

To concatenate numeric or datetime datatypes, you must use the convert function:

select "The due date is " + convert(varchar(30), 
    pubdate)  
from titles 
where title_id = "BU1032" 
--------------------------------------- 
The due date is Jun 12 1986 12:00AM             
  
(1 row affected)