If the defendant prevails in the action or if the action be discontinued the damages sustained by the defendant by reason of the taking and detention or sale of any property attached by reason of any injury thereto shall be assessed and the defendant shall have judgment therefor.
Wis. Stat. § 811.21