Is he neutered? If not it will help.
My dog is neutered and marks like a wild man but only outside. You can break him of indoor marking but you have to catch him. Try keeping a leash on him and as soon as you see that leg start to go up: "NO" and take him outside immediately. When he pees outside "GOOD BOY! and give him a treat.
Training can tough but you will save a fortune on doggie diapers