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.
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'
Couple mistakenly served bag of cash at McDonald's drive-thru