The present paper is devoted to the study of the asymptotic behavior of the value functions of both finite and infinite horizon stochastic control problems and to the investigation of their relation with suitable stochastic ergodic control problems. Our methodology is based only on probabilistic techniques, as for instance the so-called randomization of the control method, thus avoiding completely analytical tools from the theory of viscosity solutions. We are then able to treat with the case where the state process takes values in a general (possibly infinite dimensional) real separable Hilbert space and the diffusion coefficient is allowed to be degenerate