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 :
- series1, chuoi2, . cycle : strings want to connect with each other.
Note :
- The + operator is similar to the CONCAT function.
- 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
You've just finished reading the article "The '+' operator in SQL Server" edited by the TipsMake team. You can save the-operator-in-sql-server.pdf to your computer here to read later or print it out. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.