ALTER PROCEDURE [dbo].[sp_DelBillProduct]
(
@BPID int
)
AS
BEGIN
declare @BID int,@TotalCount int, @OverCount int,@Flag int
begin tran
  delete TBillProduct  where BPID = @BPID
  select @BID = BID from TBillProduct where BPID = @BPID
  select @TotalCount = TotalCount,@OverCount = OverCount,@Flag = Flag from TBill where BID = @BID 
  if @@error<>0
  begin
    ROLLBACK TRAN
    return 
  end
  
  if @TotalCount -1 = 0
     begin
     set @Flag = 1
     end
  else
     begin
     if @OverCount = @TotalCount -1
        begin
        set @Flag = 2
        end
     end
  declare @Remain int
  set @Remain = @TotalCount -1
  update TBill set TotalCount = @Remain,Flag = @Flag where BID = @BID
  -- select @TotalCount-1 as Remain,@OverCOunt,@Flag
   if @@error<>0
    begin
      ROLLBACK TRAN
      return
    end
commit tran   ENDupdate TBill set TotalCount = @Remain,Flag = @Flag where BID = @BID没有执行!
而我测试用select都时正常的。为什么啊?晕啊