Sandoval's two-run home run in the bottom of the sixth sealed the victory.
Ryan Vogelsong (13-9) pitched six innings for the Giants, surrendering only one run from Chase Headley.
Casey Kelly allowed two runs on seven hits and four walks over 4 1/3 innings for the Padres, who have lost three of their last four games.
The Giants have won nine of their last 10 games and could potentially clinch the Western Division as early as Saturday.
Rosie O'Donnell unveils nearly 50-pound weight loss
Putin thinks Obama would save him if he were drowning