我有 2 张桌子:
Table 1
和Table 2
. 我想做的是,我想使用触发器将新插入的记录从 Table1 复制到 Table2。我在 Table1 上创建了触发器,当 table1 中插入大量数据时,它将复制 Table2 中新插入的记录。它适用于单行插入,但不适用于多行插入。请让我知道,这有什么问题?
CREATE TRIGGER [dbo].[TRIG_TABLE1]
ON [dbo].[Table1]
AFTER INSERT AS
IF @@ROWCOUNT >=1
BEGIN
INSERT INTO Table2
(CustID
,DateCreated
,DateModify)
SELECT i.CustID
,i.DateCreated
,i.DateModify
FROM Table1 as i
WHERE (i.CustID IN (select CustID from INSERTED) and i.DateCreated IN (select DateCreated from INSERTED))