ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 277.8k

How to rewrite update statment with best practise and performance ?

Jan 4 2022 8:35 PM

I work on SQL server 2014 I need to rewrite update statement with best practice

CAN I Write it without subquery ?

  UPDATE  FFFFF
SET  FamilyGroup = STUFF(
(		
SELECT   DISTINCT '|' + CAST( ISNULL(REPLACE(f.FamilyGroupText,'|','/'),'NULL') AS NVARCHAR(50))
FROM ExtractReports.dbo.MultiMask FF 
INNER JOIN Parts.Nop_Part ptt WITH(NOLOCK) ON ptt.Masked_ID=ff.Masked_ID AND ptt.Masked_ID = FFFFF.Masked_ID
left JOIN [Parts].partscrubbing LC WITH(NOLOCK) ON ptt.PartID=LC.PartID
LEFT JOIN  Parts.ZFamilyGroup f ON f.ID=LC.Generic_3
WHERE ff.Masked_ID=FFFFF.Masked_ID
        FOR XML PATH ('')
	
),1,1,'')
FROM  ExtractReports.dbo.MultiMask FFFFF

 


Answers (3)