Why does inside my anal have sharp pains from time to time been going off and on for 1 year

Anal fissure. This is a small longditudinal split through the anal mucosa. There is often a small anal tag present. Painful if & when a large hard bowel monement is passed. Easily treated by an anal dilatation & removal of skin tag if necessary. Suggest you consult a proctologist, colorectal or general surgeon. In mean time suggest you trty & keep your bms soft.