Just pump the water out from above through a floor grate.
As long as the building destroyer can't path to the floor grate he can't destroy/deconstruct it.
That would work too. I'd use a few pumps dispersed evenly through the hall so you don't have to deal with too much evaporation. It would likely require more power (or useless idling dwarves), but would have less complexity than timed retracting drawbridges. You also don't have to worry about the possibility that something doesn't drown, and the bridge either won't open (too large a creature) or drops an enemy into part of your fortress (the collection area).
I had a similar trap, it was intended to push building destroyers down a pit, and the bridge would close and trap them there. It had a failsafe, if the bridge couldn't retract then it would stay sealed until I could pump magma in to obsidianize it.
if you have a 3 tile wide hallway, you may be able to perform a similar setup.
Side view:
------------------------------------
Z5 - ║~◄% ║
Z4 - ║~║~~~║
Z4 - ║~║~~~║
Z3 - ║#╠╬╬╬╣
Z2 - ◄% ║ ◄%
Z1 - ║≈║___╠╬╣≈≈≈║
Z0 - ║≈≈≈≈≈≈≈≈≈≈≈║
------------------------------------
Legend:
------------------------------------
Wall: ║╠╬╣
Pump: ◄% - Pumps west, includes a grate where necessary
Floor: __
Water: ≈
Magma: ~
Floodgate: # - Happens to have magma on top
On Z1 we have two pumps, one that acts as a "vacuum" and another that supplies the water. They link back to the same reservoir, but that's optional. Note that the supply pump on the east side has a wall between it and the room, this diagonal should cut off pressure and stop the water from rising too high. There are other methods to control the height if this fails. Z3-Z5 is a measured magma reservoir that can be dropped whenever needed. It should supply just enough magma to obsidianize the bottom 3 floor tiles. This simple design can be expanded for each tile in length that the hall needs to, but is pump heavy. Further optimization could occur, but it will likely depend on the length of the hallway.
Also, I'd like to note that its possible the water supply pump's pressure release would still cause the water to rise up to Z2, which will cause for incomplete obsidianization. If this happens I suggest using a similar method to measure the amount of water to release, similar as to whats done with the magma.
This way, if something decides not to drown, you can still eliminate it, and get some obsidian in the process.