It all depends on the ship and its location in the water.
If the main deck of a stranded vessel is above water, salvagers patch the holes that caused the ship to sink and pump out the water. The lightened ship will then refloat.
If the main deck is submerged, but not deeply, it is possible to build a waterproof wall, called a cofferdam, that extends around the deck and above the surface. Once the cofferdam is in place, the water in the cofferdam is pumped out and the vessel is patched and refloated.
Another method, known as foam-in-salvage, works by displacing water with urethane foam. A diver armed with a massive hose fills the ship with a mixture of liquid polyol, fluorocarbon gas, and liquid isocyanate, which combine to form a quick-hardening, lightweight foam.
The foam forces water out of the ship, and the buoyancy of the foam raises the ship to the surface. Two similar methods call for expanded plastic beads and hollow polystyrene balls about the size of pumpkins instead of foam.
Ships weighing less than a thousand tons can be hauled to the surface by floating cranes and then pumped out. Barges and other comparatively small vessels are often raised with pontoons, which, having been filled with water and chained to the distressed craft, are then pumped full of compressed air. The giant balloons float to the surface, pulling the attached ship with them.
Divers recover heavier ships by passing thick wire cables under the wreck and anchoring them on two attending lift craft, which are moored on either side of the sunken ship.
First, the lift craft take on ballast water to increase their draft. At low tide, when the laden craft are riding very low in the water, the rescue crew pulls the cables taut. The lift craft release their ballast with the rising tide, thereby raising the sunken ship the combined height of the new tide and the decreased draft of the lift boats.
The downed ship, dangling as if in an underwater hammock, is then regrounded in shallower water, where the whole process is begun anew, and subsequently repeated until the sunken ship rests above water and can be drained.
By employing one or a combination of ship-raising techniques, salvagers have the technology to recover virtually any vessel. Often, however, physical and financial risks conspire to make a raising unfeasible, which is why even the world’s most famous shipwreck, the Titanic, will probably never be raised.