Today's question comes from Julian.
I have a table with several fields including
updatedateas well as other tables. I am trying to create a trigger that fires upon insert and update to the table. What I want it to do is to put the current date and time (
I have tried various ways of doing this using an
UPDATESQL statement but this just updates every record in the table. I have tried to limit the records changed by using a
WHERE TABLE.RECORDID = INSERTED.RECORDIDbut this just produces an error about
inserted.recordidnot existing. I tried an
UPDATEstatement on the
INSERTEDtable but SQL complains that I can't update the
How would I go about doing this? Thanks!
The problem is likely that you are not referring to the
INSERTED table in
UPDATE Statement. I have found the following code is the simplest,
most straightforward way to approach this:
This will work for
|Read Other SQL Guru Questions|