From a trigger perspective you have a couple options:
for insert
trigger; must be defined against the base table; this trigger will fire after the data has been inserted to the table; the trigger would be coded to perform updates against the base table of the newly inserted row
instead of
trigger; must be defined against a view (the view would be defined against the base table); you would perform your insert against the view which would cause the instead of
trigger to fire; the trigger would be coded to copy/manipulate the data from the inserted
pseudo-table and write the final data set into the base table
See create trigger for more details.
Another option would be to write a stored procedure that does all of the pre-insert changes; instead of inserting directly to the base table you would call the stored proc (passing in all of the column values as input parameters). [granted, less than ideal]
'course one other option would be to have the application perform the pre-insert checks and edits before inserting the final data set to the base table.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…