(CNBC) The S&P 500 closed at a record Friday, helped by gains in technology stocks on the last trading day of the quarter.

The tech-heavy Nasdaq composite rose more than half a percent to an all-time high. The Dow transports and small-cap Russell 2000 also hit record highs.

The Dow Jones industrial average closed up nearly 24 points, within 0.1 percent of its record high. Goldman Sachs contributed to the most to gains in the index.

The index posted quarterly gains of 4.9 percent its eighth straight quarter of gains for the first time since 1997.

Note: Read our discussion guidelines before commenting.