The following are some of the built-in splice functions in SQL Server:
1. CONCAT: Splice two or more strings together. The syntax is:
CONCAT (string1, string2, ...)
Example:
SELECT CONCAT('Hello', ' ', 'World') as combined_string;
输出结果为:Hello World
2. CONCAT_WS: Similar to CONCAT, but you can specify a separator. The syntax is:
CONCAT_WS (separator, string1, string2, ...)
Example:
SELECT CONCAT_WS('-', 'First', 'Second', 'Third') as combined_string;
输出结果为:First-Second-Third
3. CONCATN: Splice multiple strings together and add specified characters between each string. The syntax is:
CONCATN (separator, string1, string2, ...)
Example:
SELECT CONCATN('-', 'First', 'Second', 'Third') as combined_string;
输出结果为:First-Second-Third
4. REPLACE: used to replace the specified substring in the string. The syntax is:
REPLACE (string, old_substring, new_substring)
Example:
SELECT REPLACE('Hello World', 'World', 'SQL Server') as replaced_string;
输出结果为:Hello SQL Server
5. +: Any type of data can be converted into strings and spliced together. The syntax is:
+ expression
Example:
SELECT 'Hello' + CAST(123 AS VARCHAR(10)) as combined_string;
输出结果为:Hello123