小编Ram*_*h S的帖子

如何判断是插入还是更新

每当在 CUSTOMER 表中发生 INSERT 时,我需要调用“ StoredProcedure1 ”并且在 CUSTOMER 表中发生 UPDATE,我需要在触发器中调用“ StoredProcedure2 ”。 如何确定是在 SQL Server 2008的触发器中插入还是更新

有人可以请帮我如何解决?

代码:

CREATE TRIGGER Notifications ON CUSTOMER
FOR INSERT,UPDATE
AS
BEGIN
DECLARE @recordId varchar(20);
set @recordId= new.Id;
    //if trigger is insert at the time I call to SP1
        EXEC StoredProcedure1 @recordId
    //if trigger is Upadeted at the time I call to SP2
        EXEC StoredProcedure2 @recordId
END
Run Code Online (Sandbox Code Playgroud)

trigger sql-server-2008 insert update

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

insert ×1

sql-server-2008 ×1

trigger ×1

update ×1