SQL Server trigger to update counter in second table -
i need solve question , i'm having serious issues working solution.
i have 2 tables, employees
, departments
. each department has counter of number of employees registered in them.
so, when insert or delete employee
, pertinent department name, need update counter of department in departments
table.
try creating (delete) trigger on employee table in after deleting employee, trigger runs , update department table.
create trigger updept
on employee
after delete
as update department d set d.empcount = (select count(employee) deptid = d.deptid) go
you may have set update query per data in table.
Comments
Post a Comment