The CCA that you deduct reduces the tax depreciation pool in respect of the building, otherwise known as the undepreciated capital cost (“UCC”). If you subsequently sell the building for an amount greater than the UCC, you will have recapture, which is fully included in your income. (If you sell the building for more than its original cost you will also have a capital gain.) Conversely, if you sell the building for an amount less than the UCC, you may have a terminal loss, which is fully deductible in computing your income.
On the other hand, land is not depreciable property. If you sell the land at a gain, only one-half of the gain is included in your income as a taxable capital gain (unless you bought the land with the intention of resale, in which case it would be fully included as income from a business.)
A special rule in the Income Tax Act (subsection 13(21.1) provides that if you sell the building and land and have a capital gain on the land and a terminal loss on the building, you must re-allocate some of the proceeds from the land to the building. Basically, the proceeds from the land, to the extent of the gain from the land, must be re-allocated to the building to reduce the terminal loss.