The '+' operator in SQL Server
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
4 ★ | 1 Vote
You should read it
May be interested
- DATALENGTH function in SQL Serverthe article will explore and show you how to use the datalength function in sql server to display the number of bytes used to represent an expression ..
- LEFT function in SQL Serverthe left function in sql server allows you to extract a substring from a large string, starting from the leftmost character.
- LEN function in SQL Serverthe len function in sql server returns the length of the specified string. it is important that the len function does not include whitespace characters at the end of the string when calculating length.
- LOWER function in SQL Serverthe article will explore and show you how to use the lower function in sql server to convert letters in a specified string to lowercase.
- LTRIM function in SQL Serverltrim function in sql server is used to delete all space characters from the first position (left positions) of the string.
- REPLACE function in SQL Serverreplace function in sql server is used to replace all occurrences of substring a to a new substring b in a given string.