Hi @ahmed salah
how to change STRING_AGG to stuff xml
Check this:
;WITH CTE AS
(
select a.RecomendationId, cast(f1.FeatureValue as varchar(300)) AS FeatureValue,f1.featureid
from extractreports.dbo.partsrecomendationActive a
inner join ExtractReports.dbo.TechnologyPlPartsFeaturValuesOrg f1 on f1.partid = a.OrignalPartId
inner join [Technology].Receipe Ft on ft.featureid = f1.featureid and ft.operatorid = 1
)
SELECT A.RecomendationId
,STUFF((SELECT '|' + FeatureValue FROM cte B where B.RecomendationId=A.RecomendationId
ORDER BY FeatureId ASC FOR XML PATH('')),1,1,'') AS DiffFeatures
FROM CTE A
GROUP BY A.RecomendationId
Best regards,
LiHong