Trigger on a view

  • Hi,

    I have a situation where I have Table A, Table B.

    View C is created by joining table A and table B.

    I have written a instead of trigger D on view C.

    I do not insert/update/delete on the view directly.

    For every insert/update in table A /B the values should get insert/update in the view respectively. This insert/update on view should invoke the trigger.

    And I am unable to see this trigger work on the view if any insert/update occurs on base table level.

    Trigger is working only if any operation is done directly on the view.

    Can anyone help me in this issue.

    Thanks in advance.

  • An index on a view is only fired if a change is made to the view. It won't fire if you insert/update the tables. Put triggers on the tables for that.

    I don't understand what you mean by ' values should get insert/update in the view respectively', because a view doesn't store data. It's just a saved select statement. It returns values based on what the data in the base tables looks like

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thank you Gail Shaw.

    I will try to write a trigger on the tables and solve this issue.

    For this line ' values should get insert/update in the view respectively' what I meant was, if any insert/update happens, they reflect on the view.

    But got a clear view on views. Thank you one

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

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