Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004

    Unanswered: 'Instead Of' Triggers particularly Update

    I am trying to understand how to use instead of trigger using an update.

    Here are a few things that I need clarified.

    - When using an 'instead of Update' trigger is this replacing any other Update that is happening to the Table.

    - Or, is the occurence of the trigger happening after the update?

    - Also, I have seen some syntax where people use:
    Update table
    set field1 = inserted.field1
    from deleted, inserted, table
    where deleted.field1 = ....

    Does this mean that when using the 'instead of' option it keeps track of
    what is being deleted and what is being inserted by using such things as deleted.field1 or inserted.field1?

    What I need to do is check that the previous value in a particular field is null before updating it. I don't want to update a particular field that already contains a value in it.


  2. #2
    Join Date
    Jun 2003
    Provided Answers: 1
    You sure you want this on a trigger? It will make it impossible to update any information in your table, even manually.

    Have you considered using this syntax in your stored procedure:

    Update	YourTable
    Set	Column1 = Coalesce(Column1, NewValue1),
    	Column2 = Coalesce(Column2, NewValue2),
    If it's not practically useful, then it's practically useless.

    blindman "sqlblindman"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts