日期:2014-05-17 浏览次数:20514 次
CREATE PROCEDURE P_Appoint @MedicalNo NVarChar (50), @MedicalName NVarChar (50), @DeptID NVarChar (50), @PeriodID NVarChar (50), @AppointTime datetime, @ManCreate NVarChar (50), @TimeCreate datetime, @ShiftID NVarChar (50), @Remarks NVarChar (100), @Descript NVarChar (100), @SNO NVarChar (50) output AS declare @Counter int set xact_abort on --这样写,当一个有错误的时候会回滚整个事务 begin tran select top 1 @Counter=SerialNO from SerialList ---取得序列号 set @counter=@counter+1 ---序列号+1 update SerialList set SerialNO=@counter ---更新SerialList set @SNO=convert(char(8),getdate(),112) + 'LW' + right(@counter+100000000,8) --日期+序列号 insert into AppointList(MedicalNo,MedicalName, DeptID,PeriodID,AppointTime,ManCreate,TimeCreate,ShiftID,SNO,Remarks,Des) values(@MedicalNo,@MedicalName, @DeptID,@PeriodID,@AppointTime,@ManCreate,@TimeCreate,@ShiftID,@SNO,@Remarks,@Descript) commit tran GO