In a constant magnetic field the spin precesses around the direction of the magnetic field. It's a nice exercise to solve the corresponding initial-value problem. The corresponding Hamiltonian is
$$\hat{H}=-\frac{q}{2m} g_s \hat{\vec{S}} \cdot \vec{B}.$$
You can go into the spin representation and use ##\hat{\vec{S}}=\frac{1}{2} \hat{\vec{\sigma}}##, where ##\hat{\vec{\sigma}}## are the Pauli matrices. If you put the ##\vec{B}##-field in the ##z## direction, it's very easy to solve the initial-value problem,
$$\mathrm{i} \frac{\mathrm{d}}{\mathrm{d} t} |\psi(t) \rangle=\hat{H} |\psi(t) \rangle, \quad |\psi(0) \rangle=|\psi_0 \rangle.$$
In the Stern-Gerlach experiment you have an inhomogeneous magnetic field, and you consider the full problem of the (electrically neutral!) particle including position. It turns out that then there's also a force acting on the particle, and thus the particle will be deflected such that you get an entanglement between position and value of the spin component along the direction of the magnetic field, i.e., an unpolarized particle beam will split up into partial beams all with well prepared spin components in direction of the magnetic field.