how did the hammer work?
if that did the trick, it's only a temp fix. The corrosion gets knocked loose by the tapping and the t-case will shift into 4x4 for a while. Then it will do it again.
a good preventative measure is to shift into 4x4 at least 1-2 times a month and drive around a bit. Gets things circulating and lubed up.