This falls under code section 1033 as an involuntary conversion. Normally no gain is recognized on property used in a trade or business unless some part of the net proceeds is not used in replacement property. If you were to pocket the proceeds and not replace the building (within the 2 year replacement period) you would have a taxable gain. code sec 1033(a)(2)(A)
You can take the 250/500K exclusion on a personal residence that has been involuntarily converted. The sale of the land within a reasonable time would also fall under this provision. The period of time that it was used as a investment real property would not fall under the personal exclusion.
The exact treatment of your situation is not exactly black an white. If you are planning on replacing the building it is very clear. If you sell the land it is pretty clear. If your decision is to not rebuild and keep the land you will be giving up some of your gain exclusion and there are more considerations.