The '+' operator in SQL Server

Learn how to use the + operator in SQL Server to join two or more strings into a string.

The article will explore and show you how to use the + operator in SQL Server to join multiple strings into a string .

Describe

The + operator in SQL Server is used to join two or more strings into a single large string.

Syntax

To use the + operator in SQL Server, we use the following syntax:

 chuoi1 + chuoi2 + chuoi_n 

Parameters :

  1. series1, chuoi2, . cycle : strings want to connect with each other.

Note :

  1. The + operator is similar to the CONCAT function.
  2. The + operator can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.

For example

Take a look and explore some examples of using the + operator in SQL Server.

 SELECT 'Quantrimang' + '.com'; 
Result: 'TipsMake.com'

SELECT 'Quan' + 'tri' + 'mang' + '.com';
Result: 'TipsMake.com''

SELECT 'Quan ' + 'Tri ' + 'Mang ';
Result: 'Quan Tri Mang'

When combining strings together, you can add whitespace characters to separate your linked values ​​for easier reading.

 SELECT 'Orange' + ' ' + 'Peach' + ' ' + 'Apple'; 
Result: 'Orange Peach Apple'

In this example, Quantrimang used the + operator to add a space character between values ​​Orange, Peach and Apple. This will help the strings not be tied together.

Previous article: CONCAT function in SQL Server

Next lesson: DATALENGTH function in SQL Server

4 ★ | 1 Vote | 👨 288 Views
« PREV POST
NEXT POST »