数据库开发
网络新概念,云计算、大数据、O2O、电商。。。。
网络新概念,云计算、大数据、O2O、电商。。。。
2017-10-12 08:39:34
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: zzv
-- Create date: 2017.10.11
-- Description: xx系统API数据同步队列
-- =============================================
ALTER TRIGGER [dbo].[TR_ZZV_TABLE]
ON [dbo].[ZZV_TABLE]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
SET NOCOUNT ON;
if exists(select 1 from inserted) and exists(select 1 from deleted)--update
begin
if(update(fstatus) or update(fname))--Column update
begin
INSERT INTO [ZZV_Sync]([faddtime],[fstatus])
select getdate(),fstatus from inserted where ftype=-10
end
end
else if exists(select 1 from inserted) and not exists(select 1 from deleted) --insert
begin
INSERT INTO [ZZV_Sync]([faddtime],[fstatus])
select getdate(),fstatus from inserted where ftype=-10
end
else if not exists(select 1 from inserted) and exists(select 1 from deleted) --delete
begin
INSERT INTO [ZZV_Sync]([faddtime],[fstatus])
select getdate(),fstatus from inserted where ftype=-10
end
END