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
 SQL Server Development (2000)
 Update Trigger only when certains are modified

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-05 : 07:14:11
Abde writes "I am looking for a syntax or to know if supported...
I would like to create trigger that is called only when certain fields of the tables are updated:


something like

describe TABLE1
field1 int,
field2 int,
field3 int

create trigger t1
FOR UPDATE ON TABLE1 ( field1,field2)
AS

.....

Trigger is called only when field1, field2 are update

Thanks for your help"

dsdeming

479 Posts

Posted - 2003-08-05 : 08:24:06
You need to use IF UPDATE ( column ):

IF UPDATE ( field1 ) OR UPDATE ( field2 )
BEGIN
do some stuff
END

However, the trigger will always be called. It's just that you can avoid doing any processing unless the specific columns you're interested in are changed.




Dennis
Go to Top of Page
   

- Advertisement -