if ( datediff (day, @today , @prctmpdate ) < 0 ) --比较 若当前日期<上次日期 ,令
--上次日期=上次日期 且 上次编号置为零
begin
update tbrecno set prenum = '1' ,predate = @today where frecord=@precrecord
end
else if (datediff(day, @today , @prctmpdate ) = 0 ) --若当前日期=上次日期 ,令上次编号加一
begin
update tbrecno set prenum = prenum + 1 where frecord=@precrecord