SQL Server 2008 R2.
I have a table that contains the locations of some of our grading centers (or potential grading centers) for a class. I also have a table with students enrolled at the grading centers. I want the site administrator to be able to delete a grading center ONLY if there are no students connected with that grading center or a facility of the grading center. How can I do that?
For instance I might have a grading center called "Colorado" with GCID of 10, and a facility in the grading center called "Colorado Facility 1" with FacID of 99. Student records associated with this grading center and facility have fields GCID and FacID that are populated with 10 and 13 respectively. If the administrator wants to delete the Colorado grading center, they should not be able to since there are student records related to it. However, if there are NO student records for this grading center or facility, I want them to be able to delete the record.
How can I accomplish this? Thanks for any help.