SQL query to convert field text format for existing nodes

Lets say you have a bunch of nodes that have all been created with the body field set to use the 'Filtered HTML' format, and you then decide that you want them to all use the 'Full HTML' format. 

You could open each item and manually change the format, or you could run a SQL query like the below (remember to also update the 'revision' field too):

UPDATE field_data_body SET field_news_stand_first_format='full_html';
UPDATE field_revision_body SET field_news_stand_first_format='full_html';

Here are the values associated with the default text formats:

  • Full html = full_html
  • Filtered html = filtered_html
  • PHP code = php_code
  • Plain text = plain_text
  • Display Suite code = ds_code
Drupal version: 
Tags: 
Justin Chevallier

Justin Chevallier

Avid Drupal site builder & user for +10 years.

Comments

Submitted by Kailash on

UPDATE field_data_field_service_dtls_description SET field_service_dtls_description_format = 'full_html';# 1 row affected.

UPDATE field_revision_field_service_dtls_description SET field_service_dtls_description_format = 'full_html';# 1 row affected.

WD php: FieldUpdateForbiddenException: field_sql_storage cannot change the schema for an existing field with data. in field_sql_storage_field_update_forbid() (line 282 of /home6/sandboy2/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

Submitted by Justin on

What type of field have you run this for? It will only with fields that allow the use of different text formats. For example it should work on fields that are of the type 'Long text' or 'Long text and summary', but it won't work for something like a regular 'text' field.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.