Here's the short version of what's below:
It is very efficient to use cage traps to catch undead, then drop them into a pit with an atom-smasher. Just be sure to have a locked/sealed door or floodgate in the doorway to the room at the bottom of the pit to keep them in place. The depth of the pit doesn't matter much since they're undead and the fall doesn't bother them too much, but it should be deep enough to keep the drawbridge from accidentally flipping them back out of it.
Unfortunately, this doesn't work as well with undead dwarves.
Getting rid of the undead has been a big issue for my current desert fortress. Primarily because I embarked along a river in a region that had two necromancer towers
relatively nearby. At first it started with the mysterious and seemingly spontaneous rise of undead mussels at the fishery workshop.
I was confused at first since I could find no necromancers listed on the units list and I was not in an evil biome (the previous evil biome I tried embarking in rained vomit almost constantly). The solution came in the form of my first militia commander who racked up an incredible kill count repeatedly slaying undead mussels so workers could carry them inside and into the atom-smasher garbage disposal room. Interestingly enough no remains would reanimate as undead once inside, so I started wondering if maybe somehow evil weather was occurring there for some reason.
Then the vultures my hunters/guards were killing started coming back as zombies. It was only a few at first, but over a few months it spread to the above ground butchery. Picture a fire elemental going into a small/medium fireworks shop and you'll have a pretty close comparison to the level of fun that quickly sparked when that happened.
Well, it took a few in-game weeks to clean up that mess with my militia working around the clock to keep re-killing zombies of nearly every animal body part you could imagine finding in a desert river area. I even lost a few war dogs, with one being one-hit killed by a zombie hair ramming itself through the dog's skull. No, not a rabbit (hare), a hair like what you find on your head. Anyways, my workers were able to slowly move all the body parts inside while the militia fought a nightmarish foe of zombified body parts.
Immediately after this I had my dwarves build a hut around/over the butchery in hopes of ending the threat of this happening again if it were weather causing it. However, it wasn't long after this that I learned the real reason why I was being plagued by this problem.
Maybe a few months later I started being besieged regularly by massive armies of the undead.
When you're besieged by 100-200+ undead being led by 2-3 necromancers it becomes dangerous and impractical to slay them with a militia and have workers carry the bodies to the underground atom-smasher. Luckily I had a wall around my fortress to keep them at bay, but I couldn't let just them loiter on my lawn and drive away caravans.
The solution I found was to build a bottle neck at one of the entrances and fill it with cage traps (maybe around 20 or so). After that was a narrow hall leading to two doors I could keep locked, but protected by several weapon traps loaded with serrated metal discs to maximize the carnage against invaders. Once the cages were filled and the traps close to needing cleaning I would close the bridge to that entrance and have my workers clean it up after the militia took care of any stragglers.
I then had the undead dropped down a pit that was about 12 z-levels deep and had an atom-smasher at the bottom of it. Any zombies that didn't explode on impact were then destroyed by the atom-smasher.
Luckily this worked on plenty of the necromancers too, which kept the undead outside the fort from being raised again after the execution of the necromancers for their crimes against life and property value.
Essentially, every few months I have to spend a few months slowly caging/shredding/dumping/atom-smashing undead and then deploying my main militia to clean up the rest once the remaining necromancers flee and there are only 20-30 or so undead left.
However, one big problem I've encountered with this disposal method is that despite the records showing the undead dwarves who make up part of the necromancer's army being from other dwarven civilizations my dwarves still treat them as though they are dead members of their own civilization. As such, the game will not allow me to dump them into the pit-of-doom or remove them from the cages to kill in other ways so I can reuse those cages. This means either dumping the entire cage into the atom-smasher room or connecting several cages to a lever to release them.