audit DML activities

  • Hi,

    I am new to sql server. I would like help from you gurus out their. I wanted to audit the activites (DML) on my database. I wanted the audit to achive the following

    1] Audit specific tables for the DML activities.

    2] capture the details of the username, time and system from which this query executed.

    3] Can i get the changed and the previous values.

    4] I don't want to use the triggers.

    I did read in some articles this is achivable with the help of SQL-profiler and osql but don't know the exact steps. Could some one provideme with the step by step guide to get this done?

    Please help,

    Rahul.

     

     

  • Without triggers it is not very easy. Triggers can meet your exact requirement.

    As you mentioned you can use Profiler tool which is UI based Tool but again you cannot query without saving them to table, moreover you cannot get old value.

    Contact me at bmlakhani@yahoo.com (Messenger) for further questions,

  • Why not use triggers? The DDL triggers are designed for this.

    If you switch c2 audit on then you will hit most requiements and get a lot more besides. Problem with previous values I think.

  • You mean DML triggers. DDL triggers monitor for changes to the schema and objects themselves.

     

    As to the original question, there are two options:

    • Triggers on the specific tables
    • Server traces

    Of these two options, triggers are probably the best fit. Server traces will tell you the query, who executed it, and when they executed it, but it can't return the information on what the original values were. That's going to require a trigger. Triggers have special tables that are used depending on the operation:

    INSERT

    • inserted - Tells you what is being added.

    UPDATE

    • deleted - Tells you what the original values were.
    • inserted - Tells you what the new values are.

    DELETE

    • deleted - Tells you what is being deleted.

    You're not going to get this information via any other built-in means.

     

    K. Brian Kelley
    @kbriankelley

Viewing 4 posts - 1 through 3 (of 3 total)

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