Imagine that I have to measure the THD with an error less than 6%, given the first 40 harmonics. How do I know the dynamic range of the spectrum analyzer that I have to use?
There's no complete but simple answer, as it depends upon the shape of the harmonics and how much margin you have. Basically the dynamic range is the level under which you can't measure the power, so you have to assume every harmonic has at least that level.
So, suppose you had equal content (or no content) at every harmonic. In that case you could get away with 10*log10( 0.06 / 40 ) = -28.24 dB. Most will surpass this by a long way!
However, suppose you had 3 dB less in every subsequent harmonic, and had a total close to 6%! In this case you would need 10*log10( 0.06 / 2^40 ) = -132.6 dB (to ensure that 40th was really not -131 dBc! Note that in this case the 2nd harmonic would only be -15.2 dBc, hopefully your amp is better than that. Supposing that the first is -20 dBc all the others could be -28.9 dBc, and you would be OK.
So hopefully these examples show you that what you really need to know is the first one or two, and assuming you aren't really close to your 6% from the get go a typical 60 to 90 dB instrument will be way more than sufficient.