DEV Community

Talemul Islam
Talemul Islam

Posted on

2 1

CONCAT_WS in SQL

Today I learn a new function in SQL. CONCAT_WS and CONCAT function returns a string resulting from the concatenation or joining, of two or more string values in an end-to-end manner. But CONCAT_WS separates those concatenated string values with the delimiter specified in the first function argument. CONCAT_WS requires a separator argument and a minimum of two other string value arguments; otherwise, CONCAT_WS will raise an error.
If CONCAT_WS receives arguments with all NULL values, it will return an empty string of type varchar(1).

Syntax

CONCAT_WS(separator, string1, string2, ...., string_n)

Example.

SELECT CONCAT_WS('+', 'It', 'add', 'with','plus sign.');
Result:
It+add+with+plus sign.
For
SELECT CONCAT('It',' only', ' concat',' string.');
Result:
It only concat string.

You can get more details about it by following the link.

CONCAT_WS
SQL Server CONCAT_WS() Function

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)