I have the following code for a trigger:
create trigger trPassDat
ON men
FOR INSERT, UPDATE
AS
declare @man int;
select @man = I.man from men U join inserted I on U.man = I.man
if Not exists (select 'True' from deleted where man = @man)
BEGIN
update men set passdate = getdate() where man = (select man from inserted)
return
END
if update(pwd)
BEGIN
update men set passdate = getdate() where man = @man
END
GO
which should update the password date: unconditionally, if we are dealing with the insertion, but the password date should be changed only if the update really changed the password.
This works in SQL Server 2000, but not in SQL Server 2005. I'm sure I did something stupid, but just in case, someone knows about some changes between SQL Server 2000 and 2005 that could affect the behavior of this trigger? Namely, the update () function?
source
share