HelloBEGIN TRANSACTION Delete a from t1 a left join t2 b on b.no=a.no left join t3 c on c.no=a.no where a.no=@no and b.no is null and c.no is null IF @@ERROR=0 BEGIN Insert into t1Deleted (no,Size,Owner,Users) values (@no,@size,@owner,@user); IF @@ERROR=0 BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION RAISEERROR('Delete Failed',1,1) Insert into tbLog (ErrorType,Msg) values ('Delete Failure','Deletion of Vessel Failed'); IF @@ERROR<>0 BEGIN RAISEERROR('Delete Failed',1,1) ENDENDENDI want to modify the above code such that:when no rows affected for the delete query, it will insert an error msg into tbLog where deletion failselse it will insert the deleted rows into t1Deleted.Something like this:BEGIN TRANSACTION Delete a from t1 a left join t2 b on b.no=a.no left join t3 c on c.no=a.no where a.no=@no and b.no is null and c.no is null if rowsAffected = 0 Insert into tbLog (ErrorType,Msg) values ('Delete Failure','Deletion of Vessel Failed');elseInsert into t1Deleted (no,Size,Owner,Users) values (@no,@size,@owner,@user);