How to trace who does "Truncate table"?

  • Hi all,

    In one database, there are 4 users having "DB_Owner" role in SQL server 2005.

    I need to trace who issues "truncate table" and save the login name and datetime to an audit table.

    Either DML or DDL can't implement it (I might be wrong). What else can I do?

    Thanks

  • Run a DML trace on the database. Check out sp_trace_create in BOL.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (11/5/2009)


    Run a DML trace on the database. Check out sp_trace_create in BOL.

    Can you let me know which trace event I should add to trace Truncate table?

  • Batch complete

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • If you know the usernames of the individuals you suspect, you could also setup a profile trace capturing UserName and NTUserName and add filter to those individuals so it only logs activity from them. Then just go through the log and you can see everything that they have done.

    Joie Andrew
    "Since 1982"

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

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