Tags

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


NEW T-SQL FEATURES IN SQL SERVER 2017- V [ CONCAT_WS() ]

In this post we shall check out the new features Microsoft introduced in SQL Server 2017 | CONCAT_WS()

New feature – X [ CONCAT_WS() ) ]

This function concatenates a variable number of arguments with a delimiter specified in the first argument. (CONCAT_WS indicates concatenate with separator.)

Notes:-

1. This function is available in following SQL Versions
SQL Server (starting with 2017)
Azure SQL Database
Azure SQL Data Warehouse
Parallel Data Warehouse

2. The syntax of the function is
CONCAT_WS ( separator, argument1, argument1 [, argumentN]… )

3. If all the arguments are null, an empty string of type varchar(1) is returned.

4. Null values are ignored during concatenation, and does not add the separator.

5. This function will return a string.

Example of CONCAT_WS()

--

SELECT CONCAT_WS( ' - ', database_id, recovery_model_desc, containment_desc,'pawan') AS DatabaseInfo
FROM sys.databases;

--

OUTPUT

--

DatabaseInfo
------------------------------------
1 - SIMPLE - NONE - pawan
2 - SIMPLE - NONE - pawan
3 - FULL - NONE - pawan
4 - SIMPLE - NONE - pawan
5 - FULL - NONE - pawan
7 - FULL - NONE - pawan

(6 rows affected)

--

Refer Microsoft LINK below for more details-

1.https://docs.microsoft.com/en-us/sql/t-sql/functions/concat-ws-transact-sql

Enjoy !!! Keep Learning

Pawan Khowal 

Http://MSBISkills.com

Advertisements