When we moved DS into his bed, we built it up to be a big deal, but we also kept the cot up in his room. We told him if he got out of bed, he'd have to sleep in the cot.
The first night he tested us within 10 minutes of going to bed - I got him and put him straight into the cot. He wasn't impressed!
The next night... Same thing. Night 3 - he knew I wasn't mucking around and he stayed in bed.

Having said that, he was almost 3, so was old enough to understand cause and effect.