Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if row data has changed 1

Status
Not open for further replies.

adddeveloper

Programmer
Dec 16, 2006
43
US
In our appliation, we have a "Close" button, that when the users click it, we update the records just in case as a safety net...this was by design when the application was first developed.

Is there a way to check to see if the whole row (about 25 columns) has changed w/o having an Update trigger for each column?

We don't want to override the "Updated Date" unless the row / any data has changed.

Thanks!
 
Triggers are NOT for Columns they are for TABLES. So you easily add:
Code:
CREATE TRIGGER ... 
     ON .....       
     FOR UPDATE
AS
  -- If that code fires something is changed 
  -- in the table no matter what column.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
You may find the CHECKSUM function useful. Look it up in books on line.



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
gmmastros,

If the user changes a letter to another letter, would Checksum() still catch that as a change?
 
Although I would seriously consider changing the application design to only update records which have actually been changed (ADO.Net has this built in for example), what you could do is: restrict all updates of the table to a stored procedure. Inside the stored procedure, check the record to see if it actually needs updating.

You could try Checksum as George suggested, or just do a column comparison. Twenty-five columns wouldn't be that bad to type out for comparison's sake. I would feel more confident doing a column comparison than relying on Checksum however.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top