CREATE Procedure eSP_ChangeStart --eSP_ChangeStart 64 @ID int, @RetVal Int = 0 Output As Declare @Badge varchar(10), @ID_Max int Begin Select @Badge = Badge From eChange_Register Where [ID] = @ID --该登记记录是否确认 IF Not Exists(Select 1 From eChange_Register Where ID = @ID and IsNull(Initialized,0) = 1) Begin Set @RetVal = 911005 Return @RetVal End Begin Transaction Update a Set a.DepID = b.DepID From Employee a,eChange_Register b Where a.Badge = b.Badge IF @Type=2 Begin Set @RetVal = 911014 Commit Transaction Return @RetVal End IF @Type=1 Begin Set @RetVal = 911091 Commit Transaction Return @RetVal End