It sounds like he's never been fully potty trained. At 2 years old he should be able to hold it longer. I think you are going to have to start from scratch as if he were a brand new puppy. Start taking him out more often, at least every hour to hour and a half. Either crate him other wise or block him off in the kitchen where there's tile floor with a puppy pad for accidents. Try and make sure you clean the carpet really well with a pet enzyme cleaner because if he keeps smelling where he's gone before he'll go right back to it. It's become a habit now. That's why I recommend you not even allow him out in the living area right now until he's trained. It could take months. It's not cruel. You can play with him where there's tile floor or outside but watch for clues that he needs to go, such as circling around in circles and sniffing around or starting to squat. Immediately grab him up and run outside with him to go. Try to always go to the same door so he will get used to that. Always praise him when he goes outside. Don't punish him if he has an accident in the house, though, or that can impede the training. He will just become fearful. Try to use positive reinforcement as much as possible. It will probably take some time but be patient. With some work you should be able to potty train him soon. Best wishes!
We have a shitzu, pug puppy also, but she is 5 months old. We are having trouble training her too! At this point, I have done alot of research and crate training seems to be the best. It would work with a two year old dog too. Basically, it's the crate at night for sleep, then they go out right away in the morning for a pee. During the day, if you can't be right with them at home, they need to be in the crate (obviously not all day)! They need to be constantly watched! You need to learn your dogs body language and schedule the feedings. Most dogs poop 40 minutes after eating. You need to clean the spot they have an accident in very well to eliminate their odor so they don't go there again, and praise them lots outside when they do go!
Peeing is our challenge for sure! Peeing can look like their just sitting. I've learned I need to keep her right with me. I have made a gate to keep her in the same room I'm in. This has made it easier for me so I'm not constantly running after her. Shitzu's are one of the hardest breeds to train I hear!!