Hi All, Please can I get some assistance with this trigger. I created the trigger and it's working. However, when I insert a new record in the payment table, it reduces all the patient_accountbalance in the Patient table. I only want it to reduce the amount for the patient that makes a payment.[code="sql"]CREATE TRIGGER [dbo].[PATIENT_ACCTBAL]ON [dbo].[Payment]AFTER INSERTASBEGIN SET NOCOUNT ON;UPDATE PATIENTset Patient_AccountBalance=Patient_AccountBalance - Payment.Payment_AmountFROM PAYMENTwhere PATIENT.Patient_ID=PAYMENT.Patient_IDEND[/code]I have attached the data in my patient table and payment table.
↧