PHOENIX (AP) -- A stomach ache struck Chad Gaudin just before he took the mound for San Francisco on Sunday.
The Arizona Diamondbacks still could do little damage against the ailing right-hander.
Gaudin, who said he threw up a couple of times while his team was at-bat during the game, pitched six strong innings for the second straight start in the Giants' 6-2 victory on Sunday.
Gaudin (2-1), normally a long reliever who was filling in for the injured Ryan Vogelsong, struck out seven and walked one intentionally.
Not that he felt great doing it.
''This came on like right at the start,'' Gaudin said. ''I thought maybe it was nerves in the beginning but it wasn't. It just kind of lingered on during the whole game. So I just had to battle it and get it through.''
The Giants took two of three in Arizona to move to 1 1/2 games behind the first-place Diamondbacks in the NL West. Colorado, a winner in extra innings over San Diego, also is 1 1/2 back.
San Francisco, 5-1 at Arizona this season, won the last two games of the series by a combined score of 16-7 after losing the opener 3-1 on a late homer by Paul Goldschmidt.
''We're a better offensive team than what we've been doing the last couple of weeks,'' Giants manager Bruce Bochy said. ''Every team goes through it. We went through a tough stretch here. It's good to see the bats come to life. It seems they got some confidence going last night and carried that into today.''
Marco Scutaro had three hits, including a solo home run, scoring twice. Brandon Belt also had a solo home run.
''The last couple of days we played as a team. We played good defense with good pitching and we scored some runs,'' Scutaro said. ''Hopefully we can keep doing that for the next series.''
Both homers came off Tyler Skaggs (1-1), who gave up five runs on eight hits in five innings.
''He didn't have very good command and he got behind a lot of guys,'' Arizona manager Kirk Gibson said. ''The first inning was kind of tricky for him. The two hits they got they didn't smash them, they dropped them in.''
The Giants got to Skaggs for four singles and a walk before he recorded an out.
San Francisco opened the game with singles by Andres Torres, Scutaro and Buster Posey to make it 1-0. Hunter Pence walked, then Joaquin Arias' RBI single put the Giants up 2-0.
Gaudin retired the first eight batters before Cliff Pennington's one-out single in the third. Skaggs reached when Gaudin bobbled his sacrifice bunt attempt, then threw wide to first, but Gerardo Parra flew out to center and Didi Gregorius struck out to end the threat.
Scutaro's solo shot high off the foul pole in left for his second home run put San Francisco up 4-0 in the fourth.
Arizona broke through with two in the fourth. Miguel Montero singled with one out, then after Martin Prado was called out on strikes, to his vehement objection that the pitch was low, Jason Kubel singled to put runners at first and second. Montero scored on A.J. Pollock's bloop single, then Kubel came home from third when Gaudin was called for a balk.
San Francisco made it 6-2 in the eighth when Gregor Blanco tripled to the right field corner off Matt Reynolds and scored on Torres' sacrifice fly to left.
There were several standout defensive plays, two of them in the first inning.
First, Arizona second baseman Pennington made a nifty over-his head catch of Juan Perez's pop foul.
Then Perez, in his major league debut, slammed into the wall in front of the swimming pool in left-center as he caught Goldschmidt's deep drive. Perez got up slowly but jogged off the field and stayed in the game.
''I was just hoping it wouldn't go out and the next thing I know he's catching it,'' Bochy said. ''What a great play he made. He bruised his ribs pretty good. After all the adrenalin rubbed off he was pretty sore.''
Perez said he felt he would be fine.
Pence, the right-fielder, caught another shot by Goldschmidt to the fence to end the fifth inning.
In the fifth, Parra barehanded Torres' hit to right field and threw to second to force out Gaudin on a nice catch by shortstop Gregorius. Gaugin had reached on the first baseman Goldschmidt's third error of the season.
NOTES: Goldschmidt was 0 for 4 and ended his string of RBIs in eight straight games, which had tied a franchise record. ... Bochy said after the game that while the MRI on Pablo Sandoval showed no damage, the third baseman could be headed to the DL. Sandoval left Saturday night's game in the third inning after aggravating a left foot strain that sidelined him for two games last week. ... The three games against San Francisco were Arizona's only home contests in a stretch of 17. ... The Giants travel to Pittsburgh, sending RHP Tim Lincecum (4-5, 4.75 ERA) to the mound against the Pirates' Gerrit Cole in Monday night's opener. Arizona goes to Los Angeles, where LHP Wade Miley (4-5. 4.92) starts for the Diamondbacks against LH Clayton Kershaw (5-4, 1.93). ... With 38,222 on hand Sunday, the total for the weekend was 120,338 - most at Chase Field for a three-game series since Sept. 23-25, 2011, also against the Giants.