update SaleOrder
set LastModified = @Lastmodified
where exists (select 1 from inserted i where i.OrderId = SaleOrder.OrderId) or
exists (select 1 from deleted d where d.OrderId = SaleOrder.OrderId) ;
UPDATE so
SET LastModified = @LastModified
FROM SaleOrder so
INNER JOIN (SELECT OrderId
FROM Inserted
UNION
SELECT OrderId
FROM Deleted) as t
ON so.OrderId = t.OrderId
或者另一种方式:
UPDATE SaleOrder
SET LastModified = @LastModified
WHERE OrderId IN (SELECT OrderId
FROM Inserted
UNION
SELECT OrderId
FROM Deleted)
2条答案
按热度按时间qojgxg4l1#
我想我会用
exists
:xxls0lw82#
如果我理解正确的话,这会更好:
或者另一种方式: