Our understanding of the solar transition region and corona largely relies on spectroscopic observations. Spectroscopy allows us to measure key parameters such as plasma density, temperature, velocity, elemental abundances and magnetic field, thus enabling us to quantitatively study the mass and energy transport processes in the solar atmosphere. Since 2006, Hinode/EIS has been obtaining high-quality EUV spectra in active regions, providing critical information to advance our understanding of different types of coronal dynamics such as active region outflows, CME-induced dimmings and persistent/decayless oscillations. Since 2013, the simultaneous imaging and spectroscopic observations with IRIS have uncovered a wide variety of fine structures and fast dynamics in the transition region, both in the quiet Sun and above sunspots. In addition, recent observations of the ground-based CoMP instrument have demonstrated the capability of imaging spectroscopy in coronal magnetic field diagnostics. With upcoming observations from Solar Orbiter/SPICE, EUVST and UCoMP, spectroscopy will continue to be an important tool for investigation of the magnetism and plasma dynamics in the upper solar atmosphere.