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)
 TRIGGER FOR UPDATE

Author  Topic 

vladimir_grigoro
Yak Posting Veteran

62 Posts

Posted - 2003-05-29 : 09:41:03
Hi All,
I want to make a trigger, which will fire when there is an update just of the 3rd column in a table. Example:

Table A
ID int IDENTITY
X CHAR(11)
Y CHAR(3)

I am trying to use such syntax to move the updated record into archive table but it don't work:

CREATE TRIGGER UPD_A
ON A
FOR UPDATE AS
IF (COLUMNS_UPDATED() & 4) > 0
BEGIN
INSERT A_ARCHIVE
...
...
FROM deleted del
END

Is there any idea about potential solution? I am using SQL Server 2000.

Thank you in advance.

The Rebel

Edited by - vladimir_grigoro on 05/29/2003 09:43:09

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-05-29 : 13:31:59
I think this is what you are looking for:

CREATE TRIGGER UPD_A
ON TableA
FOR UPDATE AS
IF UPDATE(ColY)
BEGIN
INSERT A_ARCHIVE
...
...
FROM deleted del
END

Hope this helps!
Owais


Go to Top of Page
   

- Advertisement -