Skip to main content
Logo
There is a newer version of Contensis. Click to find out more and download the latest version.

Delete old form posts with SQL

If you've been using the Contensis forms module for a while and have not kept on top of managing your form responses you might need to clear down a lot of historical form data.

It is possible to delete form posts over multiple pages in the form response viewer, but you may find it easier to use the following SQL queries against your CMS database to delete the form data.

Note: We highly recommend you have a backup of your CMS database before executing any of the following queries in a production system.

By date

Find the form posts

To locate all form posts created before or on the 10 January 2015:

SELECT * FROM FP_FormPosts WHERE FP_Created <= '10/01/2015'

Delete the form posts and associated form data

Warning: Executing the following query will permanently delete all form posts and associated form data created before or on the 10 January 2015.

DELETE FROM FPD_FormPostData
WHERE FPD_FP_ID IN (
    SELECT FP_ID FROM FP_FormPosts WHERE FP_Created <= '10/01/2015'
    )

DELETE FROM FP_FormPosts WHERE FP_Created <= '10/01/2015'

By date and form

Find the form posts

  1. Locate the form in the Project explorer that you want to clear down form responses for.
  2. Click on the form and select Information from the context menu.
  3. Make a note of the Content ID.
  4. Execute the following query to locate all form posts created on or before the 10 January 2015 and that came from the specified form by replacing <Content ID> with the noted Content ID e.g. 1234.
SELECT * FROM FP_FormPosts WHERE FP_Created <= '10/01/2015' AND FP_C_ID = <Content ID>

Delete the form posts and associated form data

Use the following query to delete all form posts and associated form data that came from the specified form by replacing <Content ID> with the noted Content ID e.g. 1234.

Warning: Executing the following query will permanently delete all form posts and associated form data created before or on the 10 January 2015 for the specified form.

DELETE FROM FPD_FormPostData 
WHERE FPD_FP_ID IN ( 
    SELECT * FROM FP_FormPosts WHERE FP_Created <= '10/01/2015' AND FP_C_ID = <Content ID> 
)

DELETE FROM FP_FormPosts WHERE FP_Created <= '10/01/2015' AND FP_C_ID = <Content ID>

By date and page

Find the form posts

  1. Locate the form in the Project explorer that you want to clear down form responses for.
  2. Click on the form and select Information from the context menu.
  3. Make a note of the Content ID.
  4. Execute the following query to locate all form posts created before or on the 10 January 2015 and that came from the specified page by replacing <Content ID> with the noted Content ID e.g. 1234.
SELECT * FROM FP_FormPosts WHERE FP_Created <= '10/01/2015' AND FP_Source_C_ID = <Content ID>

Delete the form posts and associated form data

Use the following query to delete all form posts and associated form data from the specified page by replacing <Content ID> with the noted Content ID e.g. 1234.

Warning: Executing the following query will permanently delete all form posts and associated form data created on or before the 10 January 2015 from the specified page.

DELETE FROM FPD_FormPostData 
WHERE FPD_FP_ID IN ( 
    SELECT * FROM FP_FormPosts WHERE FP_Created <= '10/01/2015' AND FP_Source_C_ID = <Content ID> 
)

DELETE FROM FP_FormPosts WHERE FP_Created <= '10/01/2015' AND FP_Source_C_ID = <Content ID>