*/ if update (title_id) and datename(dw, getdate()) in ("Saturday", "Sunday") begin rollback transaction print "We do not allow changes to " print "primary keys on the weekend." end.The example prevents updates to the primary key on weekends, and prevents updates to the price or advance of a title, unless the total revenue amount for that title surpasses its advance amount.
A primary key is the unique identifier for its row and for foreign-key rows in other tables.
Generally, you should not allow updates to primary keys. create trigger cascade_utrig on titles for update as if update(title_id) begin update titleauthor set title_id = inserted.title_id from titleauthor, deleted, inserted where deleted.title_id = titleauthor.title_id update roysched set title_id = inserted.title_id from roysched, deleted, inserted where deleted.title_id = roysched.title_id update salesdetail set title_id = inserted.title_id from salesdetail, deleted, inserted where deleted.title_id = salesdetail.title_id end An attempt to update a primary key should be taken very seriously.