我在 SQL Server 中有两个表:
- 人
- 人物历史
每次有人更新Person
表时,我都会运行此触发器以在PersonHistory
表中存储一条记录:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [TU_Person]
ON [Person]
AFTER UPDATE
AS
SET NOCOUNT ON
INSERT
INTO [PersonHistory]
([Field1], [Field2],[Field3],[Field4],[Field5],[Field6], [LastUpdated], [LastUpdatedBy])
SELECT [Field1], [Field2],[Field3],[Field4],[Field5],[Field6], [LastUpdated], [LastUpdatedBy]
FROM deleted
问题是我不断向此表添加字段,而忘记将字段添加到此触发器。有没有办法重写这个触发器来简单地说insert *
,Select *
而不是一一列出所有的字段名称?