SQL Server 2017 released with very impressive feature in many parts one of this parts T-SQL enhancement and we have a lot of new feature in this part today I will explain one of them Contact_WS function , in SQL Server 2012 Microsoft added new feature in T-SQL called CONCAT function that is returning string by joining two or more string values , but now in SQL Server 2017 we have new function called CONCAT_WS Sometimes in some cases in our code we need to join some string value but with adding some marks or separator now we can do it easily with CONCAT_WS
Example: in our Stored procedures sometimes we need to concatenate 3 columns (First name, Middle name, last name) to show for the user as one statement
In CONCAT Function we can return this result by the below T-SQL we will add after each string empty space
Select CONCAT (‘Satya ‘,’Nadella ‘,Microsoft ‘,’CEO’)
But in CONCAT_WS Function we can return the same result by adding one empty space as value to join us with the other string values
Select CONCAT_WS (‘ ‘,’Satya’,’Nadella’,’Micrsoft’,’CEO’)