Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing previous value of field in update trigger

Status
Not open for further replies.

gamcall

Programmer
Aug 23, 2000
24
GB
Hi All,
How does one refer to the value of a field _before_
it is updated. ie you would have code;
...
if update(<field>)
if ??<syntax for prev. value>?? <> NULL
Begin
...

ie, I need to execute the remainder of the trigger based
on the a) the fact that <field> is being updated & it's previous value was not NULL (for example). I can't use the value for field in INSERTED, as that is the value it's being changed _to_, not _from_. Can anyone help?

Thanks,
GAM
 
You are right that the [tt]inserted[/tt] table holds the row values after the event, but don't forget that the [tt]deleted[/tt] table holds the values from before the event.
 
Hai GAM,

Use the &quot;Deleted&quot; Table in the trigger. It holds the values of fields before Update
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top