Search and Replace in SQL

Nov 07
0

Search and Replace in SQL

Tue, 2006-11-07 23:58 — budda

If you ever find the need to do a bulk search and replace in a text field of a database table you can do it without the need for external scripts thanks to a small bit of SQL.

UPDATE [table_name]
SET [field_name] = 
REPLACE([field_name],'[string_to_find]','[string_to_replace]');

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options