Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • clinco 1 post 23 karma points
    Apr 11, 2011 @ 13:38

    Error deleting template (SQL helper exception in ExcuteNonQuery) v4.7

    I have search around the forum but can not find previous posts.  When we attempt to delete/remove a template that is no longer in use we are receiving the following error- Error handling action: Umbraco Exception (DataLayer): SQL helper exception in ExecuteNonQuery.  If we create a new template and attempt to delete it immediately it works fine.   There are several templates that can not be removed; however, they can be renamed and moved around (under different master templates, etc).

    Setup info

    Windows 2008 R2 IIS7.5
    SQL Server 2005 SP3
    Umbraco 4.7 (upgraded from original v4.5 installation to v4.6 then to v4.7)


  • dillorscroft 195 posts 189 karma points
    Apr 11, 2011 @ 17:19

    I've just come across the exact same issue.  

    Any ideas anyone?

  • Laurence Gillian 595 posts 1212 karma points
    Apr 18, 2011 @ 19:19
    Laurence Gillian

    Just come across the same issue too!

  • Sony 20 posts 40 karma points
    Apr 22, 2011 @ 09:05

     i too had this issue..

    i tried deleting references(nodes at content section) related to the templates and even from recycle bin..

    it worked

  • jivan thapa 194 posts 660 karma points
    Apr 24, 2011 @ 00:57
    jivan thapa

    if you did not assign template. Open Any document type and assign template first. back to template and delete. it worked for me.

  • Matt Taylor 820 posts 1922 karma points
    Jul 25, 2011 @ 10:50
    Matt Taylor

    I just had the same problem. I couldn't find any references to the template being used within the content or doc type structure.

    Jivan's answer worked for me. I just assigned the template to one of the doc types and then I was able to delete the template.



  • Tony Bolton 83 posts 109 karma points
    Aug 02, 2011 @ 22:23
    Tony Bolton

    At the risk of sounding like a 'me-to', I can also confirm Jivan's answer sorted out the problem.

    Close call - nearly resorted to tweaking the database - yikes!

  • Henri Toivonen 77 posts 111 karma points
    Dec 05, 2011 @ 12:16
    Henri Toivonen

    Wow, weird bug. And it's still there with 4.7.1

  • Jarrod McGuire 1 post 21 karma points
    Feb 09, 2012 @ 15:41
    Jarrod McGuire

    Can confirm as well that the post from jivan helped me out. I had deliberately removed the template associations first because I thought that would have caused the error! Who would have thought...

  • Jeroen Breuer 4861 posts 12132 karma points MVP 3x admin c-trib
    Feb 09, 2012 @ 15:51
    Jeroen Breuer

    Could also be related to this:


  • Palak 3 posts 24 karma points
    May 29, 2012 @ 10:52

    I was facing the same problem. But assign any document type with the template we want to remove first. Then go back to that template and delete it. This worked for me.

  • Kyle Skrinak 272 posts 327 karma points
    Jul 19, 2012 @ 20:53
    Kyle Skrinak

    Worked for me too, but does the business rule follow? Wouldn't you want to only be able to delete non-linked objects?

  • suzyb 459 posts 870 karma points
    Dec 18, 2012 @ 12:49

    Over a year later and Jivan's solution worked for me on version 4.9.1.

  • Troels Larsen 75 posts 280 karma points
    Dec 20, 2012 @ 18:00
    Troels Larsen

    Dont u get a more detailed description in the log ? should tell u what relation it has problems with. 

  • Luke Alderton 191 posts 508 karma points
    Mar 19, 2013 @ 14:13
    Luke Alderton

    Same problem on 4.11.5, Jivan's answer corrected the problem. Maybe this is an issue that needs looking into?

  • Pavel Gurecki 55 posts 158 karma points
    Apr 04, 2013 @ 13:33
    Pavel Gurecki

    Same problem on v6.0.3, Jivan's solution worked

  • Robert 11 posts 31 karma points
    May 24, 2013 @ 11:01

    Worked for me too. Thanks!


  • Dan Diplo 1490 posts 5791 karma points MVP 4x c-trib
    Jun 11, 2013 @ 21:52
    Dan Diplo

    Unbelievably this is still true in 6.11!

  • Sebastiaan Janssen 4880 posts 14554 karma points MVP admin hq
    Jun 24, 2013 @ 12:27
    Sebastiaan Janssen

    Would love to fix it but I don't know how to reproduce the issue. If anyone can tell me what I'm missing I can have a look:

  • Funka! 398 posts 660 karma points
    Aug 31, 2013 @ 03:15

    Here are some more detailed steps to reproduce this problem which still exists in 6.1.3. There are a few weird conditions I think others have been missing in trying to reproduce this. I just ran through this very carefully and can reproduce this 100% of the time now. Here's how:

    1. Create a new Document Type called "Deleter Tester" and leave the "Create matching template" box checked.

    2. Create a new document in your site based on this new DeleterTester document type. Name it "Deleter Doc".

    3. Now hit the "Save and Publish" button to ensure this page gets published. (Note that the Audit Trail now has two saved versions of this document in the cmsDocument table.)

    4. Go back to settings and edit the "Deleter Tester" document type. UNCHECK all allowed templates and save the document type.

    5. Now go try to delete the "Deleter Tester" template. (In my case, this was created by default as an MVC view but same problem exists in older WebForms/master pages as well if I recall.) You will get a SQL Exception because of the foreign key reference from cmsDocument to cmsTemplate

    The weird thing is this:

    • If you delete the "Deleter Doc" content node, and then purge it from the recycle bin, you can now delete the template. (Historical audit trail was wiped, no more database references to the cmsTemplate table.)

    • Or, if you go back to any document type and allow the "Deleter Tester" template as one of the choices, ... for some reason now when you try to delete the template, it somehow knows to clean up the old historical references in the cmsDocument table and actually lets you delete the template??

    So. There you go! Hope this helps....

  • Dan Diplo 1490 posts 5791 karma points MVP 4x c-trib
    Aug 31, 2013 @ 12:35
    Dan Diplo

    Nice work, Funka - great to have a definitive way of showing this in action. Hopefully it will help get it fixed.

  • Dincer M. 35 posts 97 karma points
    Dec 27, 2013 @ 04:57
    Dincer M.

    Umbraco v6.1.6 (Assembly version: 1.0.5021.24867)

    Same problem, same solution :-)

  • Benjamin Stengaard 27 posts 141 karma points
    Mar 19, 2014 @ 11:34
    Benjamin Stengaard

    Umbraco v 7.0.4 (Assembly version:1.0.5161.21054 )

    Same problem, same solution... :-)

    Here anyone reported this ??

  • Dan Diplo 1490 posts 5791 karma points MVP 4x c-trib
    Mar 19, 2014 @ 21:05
    Dan Diplo

    Yes, I reported it here ->  

    Kinda felt that no one believed me, though :)

  • Mark 49 posts 130 karma points
    May 15, 2014 @ 06:45

    think I've fixed this in a pull request -

    was a highly anoying bug!

  • Tom Fulton 2030 posts 4989 karma points c-trib
    May 17, 2014 @ 06:24
    Tom Fulton

    Woohoo - nice work, Mark! #h5yr

  • c0deguy 2 posts 22 karma points
    Dec 30, 2014 @ 21:42

    ironically after all this time and with the newest 6.2 install...this is still the fix, I can confirm you do indeed have to assign it (use it) before deletion can be completed.  really awkward bug.

Please Sign in or register to post replies

Write your reply to: