hi
below commands blocks one another , both are using same table "marketplace_items " .
merge , update happen on same table with deferent SP,
how to segregate this process to prevent from blocking?
Query 1 SPID- 171 (merge)<?query --
with e as (
select *,row_number()over(partition by sku order by sku) row from #tmp
), f as (
select * from e where row = 1
)
merge into marketplace_items as target
using f as source on source.sku =target.sku and target.marketplace_id =6
when matched then
update set
confirmed=getdate(),
confirmed_price=case when isnumeric(source.price)= 1 and source.price not like '%[a-z]%' then source.price end,
confirmed_status=left(source.[PUBLISH STATUS],500),
confirmed_status_reason =left(source.[STATUS CHANGE REASON],1000),
confirmed_category = left(source.[PRODUCT CATEGORY],500),
confirmed_qty=case when isnumeric(source.[INVENTORY COUNT]) =1 then source.[INVENTORY COUNT] end,
confirmed_ref_code=left(source.WPID,500),
confirmed_ref_number=source.[ITEM ID],
confirmed_upc=source.UPC,
confirmed_shelf=left(source.[SHELF NAME],500),
confirmed_shelf_path=left(source.[PRIMARY CAT PATH],500),
confirmed_reviews=case when isnumeric(source.[REVIEWS COUNT]) =1 then source.[REVIEWS COUNT] end,
confirmed_rating=case when isnumeric(source.[AVERAGE RATING]) =1 then cast(source.[AVERAGE RATING] as money) end,
confirmed_searchable=left(source.[SEARCHABLE?],500),
status= left(source.[LIFECYCLE STATUS],500),
response_message=left(source.[STATUS CHANGE REASON],500);
--?>
Query 2 SPID- 170 (update) <?query --
update i set
last_posted_qty = t.qty,
last_posted_qty_feed = t.feed,
last_posted_qty_ts = getdate()
from marketplace_items i join #tmp t on t.id = i.id
--?>
Query 3 SPID- 172 (update)<?query --
UPDATE marketplace_items SET confirmed_leadtime=@p0,confirmed_leadtime_ts=@p1 WHERE ID = @id
--?>