Sunday, 29 December 2019

CONCAT_WS() function In SQL Server 2017


Using CONCAT_WS() is simple and straight forward. We have to specify the separator in the form of char, nchar, varchar or nchar as the first argument. Then we can pass on the variables to concatenate in the subsequent arguments. This function will ignore NULL.
CONCAT_WS indicates concatenate with separator
Syntax
CONCAT_WS (separator, argument1, argument2 [, argumentN]...)
See the example
SELECT CONCAT_WS(',','Bagesh', 'Kumar', 'Singh') AS Full_Name;
SELECT CONCAT_WS('-','Bagesh', 'Kumar', 'Singh') AS Full_Name;
SELECT CONCAT_WS(',','Bagesh', 'Kumar', null,null,'Singh') AS Full_Name;

 

Popular Posts