UPDATE TA
SET TA.IsDetailDisplay = TB.Isdetaildisplay,
TA.Sortno = TB.Sortno,
TA.modified = getdate()
From Mstinventorysheetsbybranch TA,#XMLTbData TB
where TA.Branchcd = TB.Branchcd
and TA.Inventorysheetno = TB.Inventorysheetno
and TA.Inventorysheetline = TB.Inventorysheetline
and exists(select 'X' from #XMLTbData TC
where TA.Branchcd = TC.Branchcd
and TA.Inventorysheetno = TC.Inventorysheetno
and TA.Inventorysheetline = TC.Inventorysheetline
)
第二种使用inner join的写法去更新数据:
UPDATE TA
SET TA.IsDetailDisplay = TB.Isdetaildisplay,
TA.Sortno = TB.Sortno,
TA.modified = getdate()
From Mstinventorysheetsbybranch TA inner join #XMLTbData TB
on TA.Branchcd = TB.Branchcd
and TA.Inventorysheetno = TB.Inventorysheetno
and TA.Inventorysheetline = TB.Inventorysheetline