我有以下用于行更新的简单触发器。它应该做的是更新更新行上的 LastUpdatedDate 列。它适用于单行更新,但不适用于从应用程序端启动的批量行更新。
ALTER TRIGGER [gc].[T_UpdateObservation] ON [gc].[GCUR_OBSERVATION]
AFTER UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- get the last id value of the record inserted or updated
DECLARE @id INT
SELECT @id = [ObservationId]
FROM DELETED
-- Update statements for trigger here
UPDATE GCUR_OBSERVATION
SET GCUR_OBSERVATION.LastUpdatedDate = getdate()
WHERE [ObservationId] = @id
END
任何人都可以提供一些提示吗?提前致谢!
干杯,亚历克斯