August 30, 2007 at 11:17 am
Hi,
We have a column syncUpdate in some tables and we need a trigger (or one for each table) which will set the current dateTime for the syncLastUpdate (dateTime) when either the row is inserted or updated (we have to ignore the syncLastUpdate column itself as this would be an infinite loop, I think).
I don't know much about DB but I think that is easly doable.
Can anyone help me with that, please?
Cheers
August 30, 2007 at 12:07 pm
can you post DDL of your sample table.
The only thing needed is an after trigger which fires on inserts and updates.
* Noel
August 31, 2007 at 4:48 am
Hi Noel!
A guy in another forum has helped us with that, the answer is:
CREATE Trigger [dbo].[contactsLastUpdate] on [dbo].[contacts] for Insert, Update
AS
Begin
Update t
set syncLastUpdate = GetDate()
From contacts t
Join inserted i
On t.id = i.id
End
Work as a charm!!
Thanks very much
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy