DDL Event Problems

  • Hi All

    I am trying to create a DDL trigger to monitor tables, procedures views and functions, when i include the events below on trigger creation it throws an exception that its not valid

    CREATE TRIGGER ddltrg_CREATE_TABLE_LOG ON Database1

    FOR CREATE_TABLE,ALTER_TABLE,DROP_TABLE,CREATE_PROCEDURE,ALTER_PROCEDURE,DROP_PROCEDURE,CREATE_VIEW,ALTER_VIEW,DROP_VIEW,CREATE_FUNCTION,ALTER_FUNCTION,DROP_FUNCTION

    What is the obvious i am missing here:-)

    Thanks for your response 🙂

  • could you post the exact error and all the code for the trigger please

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Hi Chris , thanks for the reply

    Msg 1098, Level 15, State 1, Procedure ddltrg_CREATE_TABLE_LOG, Line 28

    The specified event type(s) is/are not valid on the specified target object.

    This is the message i get when i try to create a trigger 🙂

  • try and remove the "1" from DATABASE1 and just have it say ON DATABASE

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • DAtabase1 is the database Name, so that cant be changed:-)

  • As I understand it , you always specify ON DATABASE and simple make sure that you run it on the correct DATABASE

    if that make sense?

    USE [MyDB]

    GO

    CREATE TRIGGER ddl_log ON DATABASE

    FOR CREATE_TABLE

    AS

    ....

    GO

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Ops that's my mistake, It worked, Thanks a LOT 😀

  • no problem at all 😉

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life

Viewing 8 posts - 1 through 7 (of 7 total)

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