Sql server trigger

USE [iscala01]
GO
/****** Object:  Trigger [dbo].[tgr_dte_02]    Script Date: 11/20/2013 16:58:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER trigger [dbo].[tgr_dte_02]
on [dbo].[SC390200]
    for delete
as
    declare @sc39001 nvarchar(35),@sc39002 nchar(2),@sc39003 nvarchar(2),@sc39004 numeric(28,8),@sc39005 numeric(28,8),@sc39006 datetime,@sc39007 datetime,@sc39008 numeric(28,8),@sc39009 datetime,@sc39010 nvarchar(35),@muser nvarchar(35);
    select @sc39001 = sc39001,@sc39002 = SC39002,@sc39003=sc39003,@sc39004=sc39004,@sc39005=SC39005,
    @sc39006=SC39006,@sc39007=sc39007,@sc39008=sc39008 from Deleted;
    select @sc39009=GETDATE();
    set @sc39010 = 'dte' ;
    select @muser = loginame from Master.DBO.SysProcesses WHERE spid = @@SPID ;
    insert into sc39_trigger(sc39001,sc39002,sc39003,sc39004,sc39005,sc39006,sc39007,sc39008,mdte,remark,muser)
    values(@sc39001,@sc39002,@sc39003,@sc39004,@sc39005,@sc39006,@sc39007,@sc39008,@sc39009,@sc39010,@muser);

 

 

 

USE [iscala01]
GO

/****** Object:  Trigger [dbo].[tgr_update_02]    Script Date: 11/20/2013 16:59:12 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE trigger [dbo].[tgr_update_02]
on [dbo].[SC390200]
    for update
as
    declare @sc39001 nvarchar(35),@sc39002 nchar(2),@sc39003 nvarchar(2),@sc39004 numeric(28,8),@sc39005 numeric(28,8),@sc39006 datetime,@sc39007 datetime,@sc39008 numeric(28,8),@sc39009 datetime,@sc39010 nvarchar(35),@muser nvarchar(35);
    select @sc39001 = sc39001,@sc39002 = SC39002,@sc39003=sc39003,@sc39004=sc39004,@sc39005=SC39005,@sc39006=SC39006,@sc39007=sc39007,@sc39008=sc39008 from Deleted;
    select @sc39009=GETDATE();
    set @sc39010 = 'updte' ;
    select @muser = loginame from Master.DBO.SysProcesses WHERE spid = @@SPID ;
    insert into sc39_trigger(sc39001,sc39002,sc39003,sc39004,sc39005,sc39006,sc39007,sc39008,mdte,remark,muser)
    values(@sc39001,@sc39002,@sc39003,@sc39004,@sc39005,@sc39006,@sc39007,@sc39008,@sc39009,@sc39010,@muser);
GO

你可能感兴趣的:(sql,数据库,server)