In this paper we present a new formulation of the boundary condition at static and moving solid walls in SPH simulations. Our general approach is both applicable to two and three dimensions and is very simple compared to previous wall boundary formulations. Based on a local force balance between wall and fluid particles we apply a pressure boundary condition on the solid particles to prevent wall penetration. This method can handle sharp corners and complex geometries as is demonstrated with several examples. A validation shows that we recover hydrostatic equilibrium conditions in a static tank, and a comparison of the classical dam break simulation with state-of-the-art results in literature shows good agreement. We simulate various problems such as the flow around a cylinder and the backward facing step at Re = 100 to demonstrate the general applicability of this new method.