Cut the top off, and leave for a week or so to dry. I'm assuming we're talking about a true cactus, and not another type of succulent. Then plant the top, and keep watering very sparingly. It'll go on growing, ignore that. In time, it'll root, and grow away as normal. Don't plant it till it's got a really good callus over the cut surface, and be very careful with the water. The danger with this is that rot gets into them all too easily.