I work on SQL server 2012 I face issue when last value added on stuff is null then
it add extra dash - on last of values when i use stuff
so How to solve issue
my issue as below :slight_smil;
item1-item2-item3-
i need to remove last dash after item3 in case of following value is null
UPDATE pp SET
pp.StringText=s.string
FROM #part pp
INNER JOIN (
SELECT p.PartID ,STUFF(( SELECT '-' + f.Value
FROM #feature f WITH(NOLOCK)
WHERE p.PartID=f.PartID AND f.IsStringFeature = 1 AND f.[Value] IS not null
ORDER BY f.orderid
FOR
XML PATH('')
), 1, 1, '') as string
from #part p ) s ON s.PartID = pp.PartID AND s.string IS NOT NULL
what i try
select isnull('-' + f.Value,'')
are this correct or not