Groups | Blog | Home
all groups > inetserver asp db > october 2004 >

inetserver asp db : triggers for UPDATE


Bob Barrows [MVP]
10/27/2004 6:42:11 AM
[quoted text, click to view]
Yes. This is fairly easy for you to test. Run this script in Query Analyzer:

CREATE TABLE dbo.a
(
apk int NOT NULL,
somevalue int NOT NULL,
CONSTRAINT PK_a
PRIMARY KEY CLUSTERED (apk)
)
go
CREATE TRIGGER dbo.TR_a
ON dbo.a
AFTER UPDATE AS
IF UPDATE(somevalue)
PRINT 'somevalue was updated'
else
PRINT 'somevalue was not updated'
go
INSERT INTO a ( apk, somevalue )
VALUES ( 1, 1 )
go
INSERT INTO a ( apk, somevalue )
VALUES ( 2, 2 )
go
INSERT INTO a ( apk, somevalue )
VALUES ( 3, 3 )
go
update a set somevalue=somevalue where apk=3


Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

ben h
10/27/2004 3:54:07 PM
I can't quite work this out: SQL server trigger for update, and I
specify a single column e.g. IF UPDATE ( statusCode ), does it return
true if the old value and the new value are the same?

Specifically, I use execute method of ADODB.Connection object, and issue
an update table statement, but i always update all (seven) columns of
the table, even if user has only changed one in the front end web form,
does the IF UPDATE() statement return true for all the columns?

Do i need to also check if inserted.statusCode <> deleted.statusCode?

AddThis Social Bookmark Button