When any territory withdrawn from a school district or community college district pursuant to this code contains a school building, site or real property, the building or site, together with the fixtures thereof, shall, upon the withdrawal of the territory becoming effective, become the property of the district of which the territory becomes a part or the whole.