Do sanctions work?

After a year's worth of diplomacy, the UN Security Council has voted in favour of fresh sanctions against Iran over its nuclear programme. The vote passed easily with 12 states voting in favour and only Brazil and Turkey voting against.
President Obama insisted the sanctions did not close the door to diplomacy but Brazil's President Lula saw the vote as nothing more than the US getting even with Iran.
Some US bloggers like Christopher Wall at Foreign Policy welcome the sanctions but don't think they go far enough:
the new resolution is better than nothing. There should be no illusion, however, that it will stop Iran's drive toward nuclear weapons. U.N. sanctions will need to be a lot tougher to have an impact on the Islamic Republic, if it is not already too late for them to have any impact at all.
Others such as Max Boot see the sanctions as an acceptance by the White House of a nuclear Iran:
'One suspects that the president has already decided that a nuclear Iran is a done deal and that the U.S. should concentrate on containment and deterrence rather than on prevention. If so, I wish the White House would just come out and say so rather than pretending that this new sanctions resolution will achieve anything.'
Whatever your view, Iran is dismissive. President Mahmoud Ahmadinejad compared the new sanctions to a 'used handkerchief' fit for the dustbin.
Sanctions have often been used in the past in countries like North Korea, South Africa and Cuba but do they work? And if not, what does?