CREATE  Procedure [dbo].[spChangeParCode] @Rresult int OUTPUT  , @OldParNo Varchar(12) , @NewParNo Varchar(12) AS
Begin

Begin Tran ChangeParCode

	Update TmpDrugH
	Set Par_No = @NewParNo
	Where Par_No = @OldParNo

	Update DrugH
	Set Par_No = @NewParNo
	Where Par_No = @OldParNo

	Update tbl_HParvande
	Set Par_No = @NewParNo
	Where Par_No = @OldParNo
	
	If @@Error > 0  
    Begin
       Set  @Rresult = 0  
       ROLLBACK TRANSACTION ChangeParCode
       RETURN @Rresult 
    End    

COMMIT TRAN ChangeParCode

Set @Rresult = 1	
return @Rresult

end