Extract to a function or a procedure
By selecting a portion of the code in a stored procedure, giving the ability to create a new stored procedure or function from that code.
All variables present in the selected code are automatically passed as parameters. The selected code is then replace by a call to the function/procedure
This will help to divide the code in sub function and been auto documented.