When you sell a rental property you will need to compute your capital gain or loss on the sale of the property to determine how much tax you will have to pay on the transaction.
The first thing that you will have to calculate is your tax basis in the property. This is determine starting with the amount that you paid for the property, unless you did a Section 1031 exchange to purchase the property. In that case, your starting basis will be determined based on the basis of the property you exchanged from. To your starting basis you will add any improvements that you made to the property, and deduct any depreciation that you have taken to determine your adjusted tax basis.
Now that you have your adjusted tax basis you will deduct this from your sales price along with any commissions and closing costs and determine your capital gain or loss on the sale of the property. Any depreciation that was allowed or allowable on the property will have to be recaptured.