July 28, 2015 at 7:15 am
Hello,
I am new here (and to sql) so i hope i don't piss any one of.
So i have a problem with combining cells: some of the cells are blank and some of the cells have NULL value.
The combined blank cells return perfect.
But the combined cells in which 1 or more contains NULL will return as NULL
0-4139-00-01OPTIONAL EQUIPMENT 139 - A -
0-4139-00-02NVG EQUIPMENT 139 - A -
0-4139-00-03NVG EQUIPMENT 139 - A -
0139-01-01BRAKE RESERVOIR NULL
A part of the script which i use is:
STUFF((SELECT ', ' + i.ac_type + ' - '
+ i.range_or_single+ ' ' + ' - ' + i.serialno_to
FROM msc_item_effectivity i
inner JOINmsc_item h
ONb.taskcard_verno_i = h.taskcard_verno_i
WHERE h.itemno_i = i.itemno_i
FOR XML PATH('')), 1, 1, '')
i.ac_type = 139
i.range_or_single = A
i.serialno_to = blank or NULL
I want the result of the blank value to be the same as the NULL value.
0139-01-01BRAKE RESERVOIR 139 - A -
Can any body please help me out?
Kind regards,
Boems!!
July 28, 2015 at 7:38 am
When doing a concatenation... NULL + anything = NULL.
Wrapping NULL values in a COALESCE or ISNULL function can convert null values into empty strings (blanks)
COALESCE(t.ColumnName, '') or ISNULL(t.ColumnName, '')
July 28, 2015 at 7:52 am
SOLVED!! Thanks a mil!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply