Whilst it will cost you some resources to demolish the building, you will also get some resources back. How much you get back will depend on the type of building you have. In some cases, demolition will be beneficial and other times you will have to pay for it.