Categories: SQL server 2017

SQL Server concat_ws function available starting 2017

SQL Server concat_ws function available starting 2017:

Concat_ws is a new function introduced in sql server 2017.

Syntax:

CONCAT_WS ( separator, argument1, argument1 [, argumentN]… )

Concat_ws will take the separator as the first argument and will then concatenate variable number of argument into a single string.

You will need a separator and minimum of two arguments or else you will get an error. Concat_ws will

ignore the null values.

Lets check the below example on concat_ws works.

create table dbo.emp
( id int,
first_name varchar(100),
middle_name varchar(100),
last_name varchar(100))

insert into dbo.emp values( 1, ‘Sam’,null,’Mellinger’)
insert into dbo.emp values( 2, ‘Tom’,’E’,’Mellinger’)
insert into dbo.emp values( 3, null,null,null)

In this example you can also see how the null values are ignored if they are not present in the argument.

 

SQL Server concat_ws function available starting 2017

 

 

 

 

 3,210 total views,  2 views today

admin

Share
Published by
admin

Recent Posts

What is slow changing dimension?

The attribute value in Dimension table are going to change slowly over time and they…

5 years ago

How to Change SQL Server Compatibility level

  Changing Database compatibility level will be required when you upgrade your database from one…

6 years ago

View Compatibility level of Database

To know what is compatibility Level check this post link. You can view the compatibility…

6 years ago

SQL Server Compatibility Level

SQL Server Compatibility level will be used to decide how SQL will use it features.…

6 years ago

View in SQL server

A view is a virtual table.  View will not store any data physically. The data…

6 years ago

SSIS :The package failed to load due to error 0xC0011008

Below is the error which I was getting today while deploying the SSIS pacakge for…

6 years ago