Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a 3rd party software package with a MS SQL Server 2005 database. One of the tables (ADDRESS) has a column MODIFYDATE which is a DateTime that should be updated each time the record is changed, but due to a bug in the software, it is not being updated.

My solution is create an UPDATE TRIGGER on the table, that buts the current Date and Time into the field.

SQL
CREATE TRIGGER trgUpdateModifyDate
   ON  sysdba.[ADDRESS]
   FOR UPDATE
AS
BEGIN
    SET NOCOUNT ON;
    UPDATE [ADDRESS] SET MODIFYDATE = GETDATE() WHERE ?????
END
GO


My question is, how do I identify which row(s) have been changed?

Thanks
Posted

1 solution

Old values are stored in deleted, and new values are stored in inserted.
Ref:http://msdn.microsoft.com/en-us/library/aa258254(v=sql.80).aspx[^]

Create a Modified On Column in SQL Server[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900