Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Help with UPDATE triger

Author  Topic 

raxbat
Yak Posting Veteran

52 Posts

Posted - 2008-05-23 : 01:35:04
Hello! I have following trigger:

CREATE Trigger ClearingFarm_Update
On dbo.ClearingFarm
For Update
As
IF UPDATE(ask)
INSERT INTO MovingAverage (broker_id, price, cur)
SELECT broker_id, ask, symbol FROM Inserted

How can I update this triger to insert only NEW values of ask?

For example, if new ask value is the same as old, I dont need to run the insert query!

Thank You

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-23 : 02:20:08
CREATE Trigger ClearingFarm_Update
On dbo.ClearingFarm
For Update
As
IF EXISTS (SELECT * FROM INSERTED i
INNER JOIN DELETED d
ON i.broker_id= d.broker_id
AND i.ask <> d.ask)
INSERT INTO MovingAverage (broker_id, price, cur)
SELECT broker_id, ask, symbol FROM Inserted
Go to Top of Page

raxbat
Yak Posting Veteran

52 Posts

Posted - 2008-05-23 : 02:24:54
Thanx!
Go to Top of Page
   

- Advertisement -