Why does the script generated by dbclear fail to clear some tables?
If you use dbclear, either to generate a script or to delete data directly in the database, you may strike a problem where the delete fails due to a foreign key constraint. dbclear tries to TRUNCATE tables if possible, and only use DELETE if necessary. TRUNCATE is much faster, but can’t be used when there’s a foreign key referring to the table. If you use the -i (include) or -e (exclude) option, and the table with the foreign key isn’t in the list of included tables, dbclear won’t know anything about the foreign key, and therefore will try to TRUNCATE when it should DELETE. The workaround for this to use the –force-delete option.
Related Questions
- I select one stored procedure for synchronization, but there appear commands for changing several tables and stored procedures in the synchronization script. Why?
- Greg Low, Development Expert Return to SQL Server tables FAQs 5. What script will select a specific record from a table?
- What is the script to manually delete all architecture objects (tables etc)?