Find and Replace in SQL database

From James Dooley's Wiki
Revision as of 14:38, 8 June 2011 by 10.30.6.195 (talk) (Created page with "If you need to find and replace a small portion of code (such as ~<username> to <url>) in a database you can use something like: update [table_name] set [field_name] = replace([...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If you need to find and replace a small portion of code (such as ~<username> to <url>) in a database you can use something like:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

Just make sure [field_name] is set correctly on both sides. Otherwise you may overwrite data.