what?
以上的代碼你怎麼知道总是rollback transcation?將全部代碼貼出來啊 !

解决方案 »

  1.   

    CREATE TRIGGER tr_inst_CheckInout ON [dbo].[CheckInOut] 
    FOR INSERT
    AS
    declare @instCheckTime datetime,@instCheckType varchar(1),@instUserId int,@instMaxDate datetime,@instMinDate datetime,@bln bit
    select @instCheckTime=max(CheckTime) from inserted
    select @instCheckType=max(CheckType) from inserted
    select @instUserId=max(userid) from inserted
    set @instMaxDate=dateadd(mi,5,@instCheckTime)
    set @instMinDate=dateadd(mi,-5,@instCheckTime)
    if not (@instCheckType='I' or @instCheckType='O')
    begin
    commit transaction
    end
    else
    if (@instCheckType='I' or @instCheckType='O')
    begin
    if  exists(select * from CheckInOut where userid=@instUserId and checktype=@instCheckType  and checktime>@instMinDate and checktime<@instMaxDate)
    begin 
    print @instCheckType
    rollback transaction
    end
    else
    if not exists(select * from CheckInOut where userid=@instUserId and checktype=@instCheckType  and checktime>@instMinDate and checktime<@instMaxDate)
    begin
    commit transaction
    end
    end
      

  2.   

    你的代码时怎么没有
    begin transaction