Better than nothing and/or it's all you've got available at the moment, yes, but unless it's a hit to the central nervous system or critical joint serious and painful enough to quickly immobilize an aggressor, I'd have reservations that a .22 rim-fire should be counted on to effectively end an attack, especially if the aggressor is drugged up as is often the case nowadays.

While they may well bleed-out and die soon from multiple bullet wounds, a mortally wounded hyped-up druggie aggressor could still do a lot of harm before they succumb and they could be fighting for their life every bit as hard as you.