Alkaline earth metals have a valency of 2.
Alkaline earth metals are located in group 2 of the periodic table, which implies that they each have 2 electrons in their outermost shells.
The electrons located in the outermost shell of an atom are called valence electrons.
Alkaline earth metals will readily react to give up those two electrons in order to gain a complete octet, which is characterized by the presence of 8 electrons in the outermost shell.
Berylium is an exception to this; since it doesn't have enough electrons to be able to obtain a complete octet, berylium will lose those two valence electrons in order to form a stable duet configuration.
As you can see, in order to form a complete octet (or duet as mentioned earlier), every one of these atoms will give up the two electrons located in their outermost shells to form 2+ cations.
The valency of the alkaline earth metals is thus said to be 2, meaning that they each have two valence electrons.