SQL SERVER 2000 trigger for Audit trail

  •  

     

    All tables will contain create and modify Time Stamps as well as create and modify users as following fields:

    ColumnName

    Type

    Comments

    Create_ts

    Datetime

    Create Timestamp

    Modify_ts

    Datetime

    Modify Timestamp

    Create_user

    Varchar(20)

    Name of the user that created the entry

    Modify_user

    Varchar(20)

    Name of the user that last modified the entry

  • Something like this should get you most of the way:

    create TRIGGER [name] ON

    FOR INSERT

    AS

    update

    set created_by = SUSER_SNAME(),

    last_modified_by = SUSER_SNAME(),

    date_created = GETDATE(),

    date_last_modified = GETDATE()

    from inserted

    where

    .Seqno = inserted.seqno;

    create TRIGGER [name] ON

    FOR UPDATE

    AS

    update

    set last_modified_by = SUSER_SNAME(),

    date_last_modified = GETDATE()

    from inserted

    where

    .Seqno = inserted.Seqno;

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply