Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Trigger to update from one table to another

$
0
0
Hi

I have two related tables where tblStaff.ID = tblStaffBookings.StaffID. How can I set triggers in tblStaffBookings that everytime a new StaffID is inserted or deleted from tblStaffBookings then tblStaff.Jobs is set to below count?

SELECT     COUNT(ID) AS Jobs
FROM         tblStaffBookings
GROUP BY tblStaffBookings.StaffID
HAVING      tblStaffBookings.StaffID = <RecentlyInsertedStaffID>

Thanks

Regards




Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>