• I guess that I did something that should be a no-no... lol!    I remember having seen this RETURN TABLE instead of a variable in a SQLCENTRAL article a few months ago, I was interested but honestly I didn't understand some crucial points and didn't push the exercise.   Baby steps for me.

    Steve I tried your code and I got 

    Msg 2010, Niveau 16, État 1, Procédure QtyOnHandNoExcl, Ligne 8 [Ligne de départ du lot 7]
    Cannot perform alter on 'dbo.QtyOnHandNoExcl' because it is an incompatible object type.

    If I get this right, your approach implies an union of the 3 tables, so 200000 rows instead of 40000-70000 and it still will work faster?