Audit trigger returning multiple records

  • Hallo

    on several tables on a MSSQL2000 db I put a couple of triggers for auditing purpose, on DELETE and UPDATE:

    CREATE TRIGGER dbo.TableAuditDel ON dbo.Table

    FOR DELETE

    AS

    INSERT INTO dbo.TableAudit

    SELECT D.*, USER_NAME(), GETDATE(),'Delete',HOST_NAME()

    FROM deleted D

    From a certain point in time the system started logging more than one record, including seemingly:

    - records edited by other users

    - records not being edited at all (with no apparent relation with the record being actually edited)

    - same identical record, recorded at slightly different intervals of time (this could be possibly due to the fact that triggers insists on related tables too, where multiple records are interested by the editing)

    It seems that this happens when multiple operators (tenths) are using the system.

    The customer is not willing to upgrade SQL Server to a newer version.

    Could you please give me any hint?

  • With the trigger code there, that's not possible. That trigger will write into the audit table the rows which were affected by the delete with the host name and user name of the person who ran the delete.

    Maybe the problem's in the update trigger?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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