MS-SQL更新触发器(多行),没有游标?
问题描述:
你好,
是否有可能创建这样的触发器:
Hello,
is there any chance of creating a trigger like this one:
CREATE TRIGGER tri_Test ON TESTTABLE FOR UPDATE NOT FOR REPLICATION AS
SET NOCOUNT ON
BEGIN
DECLARE @Field1 varchar(31)
DECLARE @Field2 bigint
SELECT @Field1 = Field1 FROM inserted;
SELECT @Field2 = Field2 FROM inserted;
INSERT INTO NEWTABLE (Field1,Field2)
VALUES (@Field1, @Field2)
END
GO
插入"中的多个行,但不使用使用游标?
我在Google上搜索了很多,并玩了WHILE和@@ rowcount,但找不到解决方案.
一个样本会很好.
我的目标不是镜像"表.
谢谢
for multiple Rows in "inserted" but without the use of a cursor?
I googled a lot and played with WHILE and @@rowcount but could not find a solution yet.
A sample would be nice.
my goal is not to "mirror" the tables.
thank you
答
为什么你不能只说
why cant you just say
insert into newtable( field1,field2) select field1,field2 from inserted