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

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay