PRINT in a TRIGGER

  • I am trying to see if a "IF" condition in a trigger is executed or not and so I am trying to use the "PRINT" command in my trigger, but nothing seems to be printing to the screen. Even though the if statement is being executed, why is the "PRINT" statement not printing anything to the screen? Am I missing something here? I also tried using "RAISERROR", but did not work.

    Any help will be greatly appreciated.

    Thanks

    Sharma

  • Try this

    CREATE TRIGGER trWhatever ON tblWhatever FOR INSERT, UPDATE, DELETE

    AS

    If conditiontomeet

    BEGIN

    RAISERROR('Yes',16,-1)

    RETURN

    END

    ELSE

    BEGIN

    RAISERROR('No',16,-1)

    RETURN

    END

    Should return one or the other to be sure what is occurring.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • To look at the message in a PRINT or RAISERROR, do I have to run my trigger in the QUERY ANALYZER????

    Sharma

  • Yes QA will be the best place to view these quickly, oherwise you have to capture the return error in code or print message.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

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

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