Cheaper solution: EF 28-135 IS. So many were sold in kit with 40D and 50D, these are widely avail. lightly used for $300 or less (I paid $250 w/hood & 72mm B+W UV MRC, all like new, shipped). It's an older design, sure... but IQ is good, build is decent, it's got USM, close focus and IS. I often recommend it and use one myself as a versatile walk-around lens and backup for my 24-70/2.8.
Less cheap solution, the 24-105 in the kit with 5DII is a good value. Build quality is better, so is dust sealing, but you won't notice much image quality diff. If you keep it and use it, turn on Peripheral Lighting Correction on the 5DII... otherwise you'll see fairly heavy optical vignetting in the corners with this lens at 24mm (this doesn't show up very much on crop cameras).
If you are using studio strobes or any sort of manual flash, the constant aperture of this lens might be preferable, over the variable of the 28-135. (Though some pros use that lens a lot for studio work and don't see the need for the much more expensive L: www.farace.com
.)
As to using it on your 40D, a lot of folks say 24-whatever or 28-whatever lenses aren't useful on crop cameras. I disagree. I find them a great walk-around solution.
Pair any of those lenses up with an ultrawide zoom specifically for your crop camera if you wish... maybe a Canon 10-22 or Tokina 12-24, for example. Oh wait, you've already got 10-20 Sigma... so just hang onto that.
Eventually you might want a wider lens for full frame, too. I just use a Canon 20/2.8 and am happy with that.
And I have 12-24 for crop, which even thought it's designated "crop only", will fit and work on 5DII as wide as about 18 or 19mm before it starts vignetting. I've tested it.
However if you shoot a lot of landscapes and such with wide angle, you simply might want to use the FF camera most for that. Certainly it will be the best choice if big enlargements with lots of fine detail and DOF from here to eternity are your goal. If so, perhaps let the crop UWA go and get a wider solution for the FF... 17-40/4 is popular and relatively affordable solution. And just use the 40D for more telephoto stuff.
If you are planning to get some primes anyway, might not need an f2.8 standard zoom, too. Only you can say. There are the more expensive Canon 24-70, as well as Sigma in similar range, and Tamron that's close. AFAIK, both the third party lenses are FF capable (I know the Canon L is).