还别说,这个问题最好的方法就是作业,建立一个作业,每5分钟执行一次以下存储过程:create proc pr_co班级
as
set nocount on--增加班级
insert classtable(班级,...)
select distinct 班级,... from studentinfo a where not exists (
select 1 from classtable where 班级=a.班级)--删除班级
delete a
from classtable a
where not exists (
select 1 from studentinfo where 班级=a.班级)go