Operators and Functions
This section covers string concatenation and functions that operate on character strings. For
string concatenation, T-SQL provides the + operator and the CONCAT function. For other opera-
tions on character strings, T-SQL provides several functions, including SUBSTRING, LEFT, RIGHT,
LEN, DATALENGTH, CHARINDEX, PATINDEX, REPLACE, REPLICATE, STUFF, UPPER, LOWER, RTRIM,
LTRIM, and FORMAT. In the following sections, I describe these commonly used operators and
functions.
String Concatenation (plus Sign [+] Operator and
CONCAT
Function)
T-SQL provides the plus sign (+) operator and the CONCAT function (in SQL Server 2012) to concat-
enate strings. For example, the following query against the Employees table produces the fullname
result column by concatenating firstname, a space, and lastname.
SELECT empid, firstname + N' ' + lastname AS fullname
FROM HR.Employees;
www.it-ebooks.info
Do'stlaringiz bilan baham: |