【发布时间】:2011-06-14 22:42:43
【问题描述】:
我有一个表 Table1,我在其上创建了一个插入/更新触发器。这会触发将 Table1 上的插入/更新记录插入 Table1_history。为了测试触发器是否正在向 Table1_history 中插入记录,我在 Table1 中插入了一些测试数据,我收到错误:
Cannot insert explicit value for identity column in table 'Table1_history' when IDENTITY_INSERT is set to OFF
Table1 和 Table1_history 的架构相同,只是 Table1_history 中多了一个“inserted_on_date”字段。
我已将 Identity Insert 设置为 ON 并且触发器工作。但是每次需要在 Table1 中插入新记录时都必须这样做吗?
【问题讨论】:
标签: sql-server triggers