Here is a shell script that I've used for some time to generate
the necessary sql to 'fix' a WordPress database when moving it from
one URL to another... i.e. from Dev to Production. Its supports
Multisite too.
Read the comments for usage examples (including the output it
generates) as well as a list of things it does and does not do
(there are some caveats).