2011-04-04 200 views

回答

1

喜歡的東西:

CREATE TRIGGER [dbo].[trigger_tablename] -- replace 'tablename' with your table name 
    ON [dbo].[tablename] FOR UPDATE -- replace 'tablename' with your table name 
AS 
BEGIN 

     insert into T_tablename_Monitor -- replace 'tablename' with your table name 
     select NewID(),ID, Name,'After Update',SUSER_SNAME(), getdate() from inserted 


END 

監控表可能看起來像:

CREATE TABLE [dbo].[T_tablename_Monitor](-- replace 'tablename' with your table name 
    [Row_ID] [varchar](36) NOT NULL, 
    [ID] [varchar](30) NOT NULL, -- replace with your type 
    [Name] [varchar](50) NULL, -- replace with your type 
    [Action] [varchar](50) NOT NULL, 
    [UserName] [varchar](100) NOT NULL, 
    [CTime] [datetime] NOT NULL 
) ON [PRIMARY] 
0

Here是如何創建一個更新觸發器