Context. X-ray spectral variability analyses of active galactic nuclei (AGN) with moderate luminosities and redshifts typically show a softer when brighter behaviour. Such a trend has rarely been investigated for high-luminosity AGNs ($ L_{bol}gtrsim 10^{44}$ erg/s), nor for a wider redshift range (e.g. $0lesssim zlesssim 5$). Aims. We present an analysis of spectral variability based on a large sample of 2,700 quasars, measured at several different epochs, extracted from the fifth release of the XMM-Newton Serendipitous Source Catalogue. Methods. We quantified the spectral variability through the parameter $beta$ defined as the ratio between the change in the photon index $Gamma$ and the corresponding logarithmic flux variation, $beta=-DeltaGamma/Deltalog F_X$. Results. Our analysis confirms a softer when brighter behaviour for our sample, extending the previously found general trend to high luminosity and redshift. We estimate an ensemble value of the spectral variability parameter $beta=-0.69pm0.03$. We do not find dependence of $beta$ on redshift, X-ray luminosity, black hole mass or Eddington ratio. A subsample of radio-loud sources shows a smaller spectral variability parameter. There is also some change with the X-ray flux, with smaller $beta$ (in absolute value) for brighter sources. We also find significant correlations for a small number of individual sources, indicating more negative values for some sources.