Check the RAM requirements in the documentation. If you have no documentation for the two machines, try the manufacturer's site. Failing that, try the model lookup features on websites of 3rd party RAM sellers like Kingston and Crucial.
You may find that the machines have different requirements. As the DIMM from one machine physically fitted in the other it must be the same overall type (as the notches on the pin edge vary by overall RAM type) but there are other differences:
- Some machines require ECC RAM, some will use either ECC and non-ECC, some will demand non-ECC
- There are many timing variants in each RAM type: some machines will accept just about anything, some will be more fussy. Also most RAM is happy to run at a variety of speeds not just it's nominal one, but some chips are more fussy than others in this respect too
- And so forth...
Of course there is the possibility that you've damaged the DIMM while taking it out.
But as you describe the old machine's state as "the motherboard is gone" the most likely case is the the DIMM was damaged by what-ever killed the rest of the motherboard (a power spike for instance, due to bad input power from the grid or faulty power regulation internally).
As a general rule if a motherboard has died I'd not trust the CPU or RAM that was plugged into it at the time. I'd be very wary of the power supply too as that may be the cause of the deadness, and I'd test anything else that was plugged into that power supply (drives and so forth) before risking relying on them in a new environment.