数据库中表student有四列
id  testweek  testday  testnoon
其中testweek可能的取值有        第一周  第二周 第三周
testday可能的取值有             星期一  星期二.....星期五
testnoon的可能取值有            上午  下午目标是       某一周的某天的上午或者下午最多有五个人可以注册为了保证最多五人注册我用了触发器,触发update操作 ,具体如下(回帖1):
但是这就需要写3*5*2=30个触发器   有什么办法   不用这样写么?

解决方案 »

  1.   

    CREATE TRIGGER  tri_update  ON [dbo].[students] 
    FOR   UPDATE 
    AS
    declare  @sum int
    select @sum=count(id)  from  students
    where testweek='第十一周' and  testday='星期一'  and  testnoon='上午'
    if @sum>5
    begin 
        raiserror('300 most!',16,8) 
        rollback tran 
    end
      

  2.   


    create trigger 触发器 on 表
    for update
    as 
    begin
    语句..
    end