Uncertainties in the next-to-leading-order calculations of heavyquark (Q) production are investigated. Predictions for total cross sections, single-inclusive distributions of heavy quarks and heavy flavoured hadrons, as well as for Q Q correlations, are compared with charm and bottom data.The description of heavy-quarkonium production requires a separation of the short-distance scale of Q Q production, which is set by the heavy-quark mass from the longer-distance scales associated with the bound-state formation. Various factorization approaches are compared, in particular with respect to the different constraints imposed on the colour and angular-momentum states of the Q Q pair(s) within a specific quarkonium state. Theoretical predictions are confronted with data on heavy-quarkonium production at fixed-target experiments and also at pp colliders, where fragmentation gives the leading-twist cross section in 1/p 2 T and 1/m 2 at high transverse momentum.