I have a simple code below.
Select columnA, columnB, columnC
From table.
Here is my result.
ColumnA ColumnB ColumnC Apple G null Juice S T9
Now, I use the concatenation as follow
Select
ColumnA + '_'+ ColumnB + '_' + ISNULL(ColumnC, '') as Name
From table
My output is as below
Name Apple_G_ Juice_S_T9
How do I modify the concatenation above so it would show as Apple_G instead of Apple_G_ Basically, I have an extra _ from my result.
COALESCE()orISNULL()functions or conditions could help. When theCONCAT_NULL_YIELDS_NULLoption is ON, you have to handleNULLvalues manually. It is always recommended to do so.