There is always the possibility that this is a skunk smell, if it came on suddenly. If it has been there awhile, then that is not it. If it did come on suddenly, you just need to bathe with the skunk-off shampoos to neutralize the odor.
Sometimes what you are smelling is the anal glands. These are glands right inside the rectum that emit a truly foul smell like old dead fish and poop. One drop can last for hours. These can be expressed, but can recur.
You may be dealing with something like yeasty seborrhea
, which is a skin condition where they start to have skin lesions and smell. This just requires frequent bathing with a special medicated shampoo to get rid of the smell, and heal the skin.
Sometimes it is an infectious cause like bacterial or fungal. Same thing--the best way to get rid of this is frequent bathing, but with a different shampoo meant to flush the follicles.
Other than that, sometimes the teeth are rotting, and sometimes they do have a smell coming from their sebaceous glands. This also is best controlled with frequent bathing, letting the shampoo sit on the dog for 10 minutes and rinsing and drying well. You usually do this twice weekly for at least three weeks.