talha m
asked on
sql server triggers
actually i am making a pharmacy maintenance project using sql server and i want to fire a trigger from dbo.SaleInfo to dbo.stockinfo using the foreign key in both tables MedID and when stock is decreamented it reduce the stock from dbo.stockinfo?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Chris
the question was
so, we only need an update trigger here...
your trigger will run in all delete/insert/update statements
your trigger will increase by qty on insert, and decrease by qty on delete row as well...
the question was
when stock is decreamented it reduce the stock from dbo.stockinfo
so, we only need an update trigger here...
your trigger will run in all delete/insert/update statements
your trigger will increase by qty on insert, and decrease by qty on delete row as well...
Hi talha m,
Please select a solution that works for you.
Thanks,
Chris
Please select a solution that works for you.
Thanks,
Chris
Answered question and provided test code for validation.
we cannot use delete trigger, Line 12...
we only need update or maybe insert...
the inserted table will be null on delete trigger...
maybe something like this
Open in new window