Query regarding Tiggers.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sonaul
    New Member
    • Jan 2007
    • 1

    Query regarding Tiggers.

    Hello,

    I am a beginner with sql and have created a trigger for daily transactions for insert and update like :

    if (condition)
    begin
    insert into customerhist(op eration) values('insert' )
    end
    else
    begin
    insert into customerhist(op eration) values('update' )
    end
    go.

    I wanted to know which of the insert or update query is executed after this trigger is fired, is there any return type or return variable or flag variable I can use to know this ??

    Please can someone help me with this.

    Happy Thoughts,
    Sonaul.
    Sonaul@gmail.co m
  • Akhilesh1505
    New Member
    • Feb 2007
    • 17

    #2
    Originally posted by sonaul
    Hello,

    I am a beginner with sql and have created a trigger for daily transactions for insert and update like :

    if (condition)
    begin
    insert into customerhist(op eration) values('insert' )
    end
    else
    begin
    insert into customerhist(op eration) values('update' )
    end
    go.

    I wanted to know which of the insert or update query is executed after this trigger is fired, is there any return type or return variable or flag variable I can use to know this ??

    Please can someone help me with this.

    Happy Thoughts,
    Sonaul.
    Sonaul@gmail.co m
    This is bsed on your condition which you provieded in if else, that statement will be executed.

    Comment

    • dorinbogdan
      Recognized Expert Contributor
      • Feb 2007
      • 839

      #3
      What does the [condition] expression contain?

      Comment

      • almaz
        Recognized Expert New Member
        • Dec 2006
        • 168

        #4
        Please submit SQL Server version as approaches may significantly differ depending on it.

        In SQL Server 2005 try playing with following code inside the trigger:
        Code:
        SELECT TE.*
        FROM sys.trigger_events AS TE
        JOIN sys.triggers AS T
        ON T.object_id = TE.object_id
        WHERE T.parent_class = 0
        AND T.name = '<<Your Trigger Name>>'

        Comment

        Working...