delete trigger on table

  • Hi,

    i want to use a trigger on a table to capture all delete activities on that table.

    i want to capture the loginame,spid,command issue.

    i try to use the EVENTDATA() to collect this info but all it give me is a NULL values.

    how can i capture this data on delete from table.

    THX.

  • You have to write your trigger.

    you can get SPID and user information by using system variables.

    SELECT @@SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'

  • what are my options to capture the issue command on the deleted rows from the table?

    THX

  • quick answer is, eventdata is used to capture event information for DDL events and used in DDL Triggers, you want to return the command for a DML Trigger.

    --------------------------------------------------------------------------------------
    [highlight]Recommended Articles on How to help us help you and[/highlight]
    [highlight]solve commonly asked questions[/highlight]

    Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
    Managing Transaction Logs by Gail Shaw[/url]
    How to post Performance problems by Gail Shaw[/url]
    Help, my database is corrupt. Now what? by Gail Shaw[/url]

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

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