Knowledge Base

How can I do a mass find and replace in articles?

Article ID: 189
Last updated: 18 Dec, 2010

You can write one-line find-and-replace statements in SQL.
To find a string in a certain field and replace it with another string:

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

To not affect date updated for the articles use following sql:

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

To find what articles will be affected:

SELECT [field] FROM [table_name] WHERE [field_name] LIKE '%[string_to_find]%';

Example: replace "apple" to "banana" in all articles

UPDATE kbp_kb_entry SET body = REPLACE(body,'apple','banana'), date_updated=date_updated;
This article was:   Helpful | Not helpful Report an issue

Article ID: 189
Last updated: 18 Dec, 2010
Revision: 1
Views: 5951
Comments: 0
print  Print pdf  Export to PDF email  Subscribe share  Share pool  Add to pool comment  Add comment
Prev     Next
Troubleshooting adding an image to an article       How can I set KBPublisher to use SSL?