Hi folks,while loop taking so much time,need to improve the performance

maybe this?

update tgt
set tgt.details=src._json
From @result tgt join
(
  select sl1.searchLogId,
         (select SearchLog.Device,SearchLog.Brand,SearchLog.Model,
SearchLog.VendorId,SearchLog.OSD,SearchLog.Edid 
		    from SearchLog sl2 
		   where sl2.searchLogId = sl1.searchLogId
FOR JSON AUTO
		  ) as _json
   from SearchLog sl1
) src on tgt.recordid = src.searchLogId
1 Like