Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Deleting/Administering Taxonomy via SQLDeleting/Administering Taxonomy via SQL
Previous
 
Next
New Post
1/26/2015 3:27 PM
 

 

Several months ago I made the error of trying to administer Taxonomies via SQL. I wanted to change the parent terms in a complex hierarchical taxonomy very quickly, but now realize it was not a good idea.

I want to start over, but am now unable to delete one this custom hierarchical Taxonomy vocabularies and all the terms it contains. 
Nothing happens when I click Delete going through the DNN web admin interface. 

I also tried to delete it using SQL: 

delete from Taxonomy_Vocabularies 
where VocabularyID = 8 

delete from Taxonomy_Terms 
where VocabularyID = 8 

but get this error (on both queries): 

Msg 547, Level 16, State 0, Line 1 
The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "FK_Taxonomy_Terms_Taxonomy_Terms". The conflict occurred in database "DNN7", table "dbo.Taxonomy_Terms", column 'ParentTermID'. 
The statement has been terminated. 

I tried making a test Taxonomy and was able to delete it just fine, using website or SQL. So it must just be this one that I tinkered with from the back end. How can I get rid of it?

 
New Post
1/27/2015 1:33 AM
 
The error that you are getting here is due to a same table reference to a record that is going wrong.

Your query is trying to delete an item with a ParentTermId value that is being used by other terms. As such, this is failing as there is a FK dependency.

YOU MIGHT Be able to do something like this

DELETE FROM Taxonomy_Terms
WHERE VocabularyId = 8 AND ParentTermId IS NULL

Then a second delete that matched your initial.

NOTE: Use at your own risk, the above is general SQL information based on the FK error that you have. NOT from full validation with DNN tables.

-Mitchel Sellers
Microsoft C# MVP, MCITP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
1/27/2015 6:06 AM
 
I would assume, the an item with parentTerm = Null is the root item, which cannot be deleted as long as there are childs.
You need to delete child items first, the statement would be:
DELETE FROM Taxonomy_Terms
WHERE VocabularyId = 8
AND TermID NOT IN (SELECT DISTINCT ParentTerms FROM Taxonomy_Terms WHERE VocabularyId = 8)

Cheers from Germany,
Sebastian Leupold (Microsoft MVP)

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
1/28/2015 11:17 AM
 
I see now. I was able to use SQL to delete all the lowest-level children, then parents, grandparents, so forth. Thanks!

But now I'm left with one term that was a parent over EVERY OTHER term in the vocabulary. And it won't let me delete this last one. Its ParentTermID is NULL.

Msg 547, Level 16, State 0, Line 1
The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "FK_Taxonomy_Terms_Taxonomy_Terms". The conflict occurred in database "DNN7", table "dbo.Taxonomy_Terms", column 'ParentTermID'.
The statement has been terminated.
 
New Post
1/28/2015 4:23 PM
 
if it is the last one, run:
DELETE FROM Taxonomy_Terms
WHERE VocabularyId = 8

Cheers from Germany,
Sebastian Leupold (Microsoft MVP)

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Deleting/Administering Taxonomy via SQLDeleting/Administering Taxonomy via SQL


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out