Concatenate strings, using ‘.’ as the separator between concatenated string values.
SELECT CONCAT_WS(‘.’, ‘www’, ‘W3Schools’, ‘com’); |
The CONCAT_WS() function concatenates two or more strings together, placing a specified separator between each string.
Note: Also consider using CONCAT() and the + operator for string concatenation.
CONCAT_WS(separator, string1, string2, …., string_n) |
Parameter |
Description |
separator |
Mandatory. Specifies the separator to be used between concatenated strings. |
String1, string2 string_n |
Mandatory. Specifies the strings to be concatenated together. |
Works in: |
SQL Server (from 2017 onward), Azure SQL Database, and Azure SQL Data Warehouse |
Concatenate strings together, using ‘-‘ as the separator between the concatenated string values.
SELECT CONCAT_WS(‘-‘, ‘SQL’, ‘ is’, ‘ fun!’); |