Remember on triggers you got 2 major tables at your disposal Inserted
and deleted

so if you want to get more complex you can do an inner join on the 2
tables and only update the update time when the actual field value
changes for instance if I ran

Update People
Set Name = 'George'
Where Name ='George'

The update trigger would fire and update the time when in reality the
field was not update.

We do this for timing our product uploads to Amazon.

Something like:
INSERT INTO Feeds (Feed_type,SKU,UpdateTime)
Select 'Product_feed', i.SKU, getdate()
FROM inserted i LEFT JOIN deleted d ON i.SKU= d.SKU
Where AND i.description1 != d.description1
AND i.>
Which basically inserts into a table that keeps track of what needs to
be sent to Amazon (and a lot of other stuff too) when the description
changes. I did it this way because the action page, for the product
edit in out CMS, just blanket updates various information, 8 times out
of 10 it is not the description getting changed. Hope that gave more
insight into triggers and did not confuse you or anyone else. If so
I'll try to confuse..I mean explain further.

Adam

On Tue, 27 Jul 2004 15:11:05 -0500, Phill B <[EMAIL PROTECTED]> wrote:
> Thanks Adam. Just what I needed.
>
> --
> Phillip B.
>
> ----- Original Message -----
> From: Adam Haskell
>
> This is the basic idea:
>
> CREATE   TRIGGER [UpdateForTime] ON dbo.Products
> FOR UPDATE
> AS
> BEGIN
> IF Not ((UPDATE(UpdateTime))
> BEGIN
> UPDATE dbo.products
> SET UpdateTime=getdate()
> WHERE Product_id IN (select product_id from inserted)
> END
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to