Avoid the modification of a specific field

  • How can using a T-SQL triggers to prevent the modification of several fields that belong to a table?

  • There are two basic ways to do this, both through a trigger:

    1) Use the Update() function to determine if any of the column(s) was SET by the update (and optionally also check the inserted and deleted pseudotable's column values for actual changes), and if so, then Rollback the transaction.

    2) Use the Update() function to determine if any of the column(s) was SET by the update and then also check the inserted and deleted pseudotable's column values for actual changes, and if so, reset the column's values back to their original (using "deleted").

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

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

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