To investigate the relative amount of ejecta from high-mass versus intermediate-mass stars and to trace the chemical evolution of the Galaxy, we have performed a systematic study of Galactic interstellar ^18^O/^17^O ratios toward a sample of 421 molecular clouds with IRAM-30m and the 10m Submillimeter Telescope, covering a galactocentric distance range of ~1-22kpc. The results presented in this paper are based on the J=2-1 transition and encompass 364 sources showing both C^18^O and C^17^O detections. The previously suggested ^18^O/^17^O gradient is confirmed. For the 41 sources detected with both facilities, good agreement is obtained. A correlation of the ^18^O/^17^O ratios with heliocentric distance is not found, indicating that beam dilution and linear beam sizes are not relevant. For the subsample of IRAM 30m high-mass star-forming regions with accurate parallax distances, an unweighted fit gives ^18^O/^17^O=(0.12+/-0.02)RGC+(2.38+/-0.13) with a correlation coefficient of R=0.67. While the slope is consistent with our J=1-0 measurement, the ratios are systematically lower. This should be caused by larger optical depths of C^18^O 2-1 lines with respect to the corresponding 1-0 transitions, which is supported by RADEX calculations and the fact that C18O/C17O is positively correlated with ^13^CO/C^18^O. When we consider that optical depth effects with C^18^O(J=2-1) typically reach an optical depth of ~0.5, the corrected ^18^O/^17^O ratios from the J=1-0 and J=2-1 lines are consistent. A good numerical fit to the data is provided by the MWG-12 model, which includes both rotating stars and novae.