UPDATE #Product_Comments
SET #Product_Comments.Comments = (
SELECT COALESCE(STRING_AGG(p.Label, ', '), '') + ' '
from (
select distinct Label, Product_ID
from #TEMPORARYTB
where Product_ID = pc.Product_id
) as p
GROUP BY p.Product_ID
) + pc.Comments from #Product_Comments pc
JOIN Product_Property p ON p.Product_ID = pc.Product_id
I used
COALESCE()
when there was just STRING_AGG(p.Label, ', ')
before, and I am still getting NULL
inside comments. If I print Product_Comments before the update, I don't see any NULL
inside comments.
SELECT *, '4' AS debug FROM #Product_Comments
I am printing it like this. So, when I do
SELECT *, '3' AS debug FROM #Product_Comments
I don't see any NULL
, which is weird. It means that the COALESCE
is not working somehow. How can I fix this?
Asked by user253549
Feb 7, 2022, 08:07 PM
Last activity: Feb 7, 2022, 08:48 PM
Last activity: Feb 7, 2022, 08:48 PM