Before Update Triggers and changing inserted recordset
-
I would like to know how I can set a new value into the triggers inserted recordset. Example: All dates on or before 1/1/1900 are to be set to null. Then a date in the fourth column comes in as 1/1/1900 in the inserted column. I can find out that the value needs to be set, but how can I change it to null before it is actually set in the database? Thanks,
Leo T. Smith Program/Analyst Supervisor
-
I would like to know how I can set a new value into the triggers inserted recordset. Example: All dates on or before 1/1/1900 are to be set to null. Then a date in the fourth column comes in as 1/1/1900 in the inserted column. I can find out that the value needs to be set, but how can I change it to null before it is actually set in the database? Thanks,
Leo T. Smith Program/Analyst Supervisor
You could use an INSTEAD OF UPDATE trigger that fires when an UPDATE statement is executed against your table. The inserted table would contain details of the changes which were going to be made. You can then examine these values and execute a different UPDATE statement which either updates the fields as they were originally going to be updated, or sets fields to NULL where the value <= 1/1/1900.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush