We analyze the non-Markovian stochastic Schrödinger equation describing a particle subject to spontaneous collapses in space (in the language of collapse models), or subject to a continuous measurement of its position (in the language of continuous quantum measurement). For the first time, we give the explicit general solution for the free particle case (H=p(2)/2m) and discuss the main properties. We analyze the case of an exponential correlation function for the noise, giving a quantitative description of the dynamics and of its dependence on the correlation time.