Suppose I have two tables
payments with columns payment_id, batch_id and batches with columns batch_id, batch_type
Can I add a trigger to prevent inserts into the payments table when the batch_id being inserted is not a specific batch_type?
In short, for the inputted batch_id I want the trigger to check in the batches table to see if that batch_id has batch_type P.
Something similar was discussed here but for MySQL (I am looking for a MS SQL trigger ) :- How to make a trigger that will compare input with a value of other table?.
Thanks for your help!