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

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 7129

Trending Articles