none
Deleting Content Types

    Question

  • I can't delete a content type from a document library in MOSS.
    Using the GUI to delete a content type from a document library gives:
    
    Content Type is still in use
    
    I have verified that all documents are assigned to a different content type 
    and I've poked around in the content database, but it doesn't look simple.
    
    Please help!
    Thanks,
    Mindy
    Tuesday, June 19, 2007 3:32 PM

All replies

  • Hey Mindy,

    The following T-SQL is not supported by anyone of note (as I just created it).  You should not use this to reverse engineer the content type process as I may be forgetting some very important link.  Please do feel free to use this T-SQL to find dependencies of this content type.  Since content types can be inherited, you may find that even though no list is using a content type, you still won't be able to delete it until you delete its child content types.  Be sure to replace 'Document' with the name of the content type you wish to look for.

    Code Snippet

    DECLARE @ContentTypeName nvarchar(128)

    SET @ContentTypeName='Document'

    SELECT w.Title AS [Web Site], w.FullUrl AS [Web Url], al.tp_Title AS [List Title], ct2.* FROM ContentTypes ct1 JOIN ContentTypes ct2 ON LEFT(ct2.ContentTypeId, Len(ct1.ContentTypeId))=ct1.ContentTypeId LEFT OUTER JOIN dbo.ContentTypeUsage ctu ON LEFT(ctu.ContentTypeId, Len(ct2.ContentTypeId)) = ct2.ContentTypeId LEFT OUTER JOIN dbo.AllLists al ON ctu.ListId = al.tp_Id AND ctu.WebId=al.tp_WebId LEFT OUTER JOIN dbo.Webs w ON al.tp_WebId = w.Id WHERE ct1.ResourceDir=@ContentTypeName

    Wednesday, June 20, 2007 5:10 AM
  • Hi Curtis,

     

    This is fantastic for finding where a content type is used across the board - thank you!

     

    I ran this on the content type I need to get rid of, but it found nothing (I ran it on another content type and it worked just fine). I just need to delete the darn thing from a particular document library.

     

    Thanks!

    Mindy

    Wednesday, June 20, 2007 10:03 PM
  • Mindy,

     

    Make sure that content type isn't associated w/ any lists.  Just b/c you don't have any documents of that content type doesn't mean the content type isn't in use.  I has a similar issue and was able to resolve it by deleting the list the content type was associated w/.  I assume you could simply change the settings on the list just as well.

     

    P

    Thursday, June 21, 2007 3:26 PM
  • Hi Purse,

     

    The problem is that I need to delete the content type just from one document library (list). The GUI will not allow me to do it and says that the content type is in use (within the doc library). It is not in use in any visible manner.

     

    Thanks,
    Mindy

    Thursday, June 21, 2007 4:08 PM
  • Hey Mindy,

     

    Upon reading your original post, I realized I overshot your original question.  Although I don't have a fantastic solution for you at this time, let me at least make you did the minimal steps for deleting a content type within a list.

    After modifying all documents within the document library to not use the content type, did you verify that the existing content type you want to delete is not the default content type?  Also, once that has been changed, have you tried to disable content type management?  Just some food for thought.

    Friday, June 22, 2007 2:45 AM
  • Hi Curtis,

     

    Yes, I did all of that. I did not disable content type management however, because I need the other content types. Are you suggesting to disable and then re-enable?

     

    Thanks,

    Mindy

    Monday, June 25, 2007 7:26 PM
  • Yes, disable, delete, then re-enable.  There is a slight chance you will be able to delete it.  Also, check the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS directory and look for the latest computername / timestamp log entry.  See if you can find any more information regarding the deletion of the content type in that log.
    Tuesday, June 26, 2007 12:34 AM
  • Well, you can't delete a content type when management is disabled. But I disabled, re-enabled, and still could not delete.

     

    There is nothing in the logs with regard to the attempt to delete the content type. Do you happen to know which diagnosic logging category reports on content type activities?

     

    Thanks,

    MIndy

    Tuesday, June 26, 2007 7:08 PM
  • The log would have the content type or some part of the error message you see in it.  How about creating a network place to the document library in question, perform a copy & paste operation into a regular Windows OS folder (possibly your desktop), delete the documents from the document library, and then try to delete the content type.  If nothing else, you should be able to delete the document library and re-create it.  Then add your documents back in once you have the updated / recreated document library in place.  Assign the content types to each document as appropriate.  Caution, this will delete all SharePoint-specific metadata (to including versioning) from the documents.
    Wednesday, June 27, 2007 5:11 AM
  • I thought about doing that, but I'm trying to avoid it as it would be a lot of work and we would have to sacrifice important metadata and versions. Maybe when Syntergy's Copy and Paste is released...

     

    Mindy

    Wednesday, June 27, 2007 6:01 PM
  • I haven't forgotten about your problem, but I don't have any good ideas either.  Maybe check your Recycle Bin for documents that may be attached to the ContentType you wish to delete.  Whenever documents are deleted into the Recycle Bin, they should no longer be referenced anywhere, so this is a long shot.  Be sure to delete the documents from the Administrative Recycle Bin as well.  If this doesn't work, I really don't have any more advice to offer you.  Sorry.
    Friday, July 6, 2007 4:04 AM
  • I had the exact same problem. Turns out that there were still references to the content type from the documents in the recycle bin. I emptied out the recycle bin, as well as the administrators recycle bin, did an IISRESET, and then I could successfully delete the content type. Not sure if you have trailing references to the content type anywhere else Mindy.

    Tuesday, August 7, 2007 9:10 AM
  •  

    Hi ..

     

    I defined a contenttype in a feature.. but you can set the guid of the contenttype and this is id sets the parent e.g.

     

    a contenttypes parent is system page, and can that be the reason that i cant delete my contenttype?

     

     

     

     

    Thursday, August 16, 2007 8:52 AM

  • Hi there
    I had the some problem ... I needed to delete some Content Types (from the GUI) created within SP Designer .
    After some hours I was able to delete all.

    - In my case, I started to delete all my WorkFlow data and then my DocLib
    - Then from the "Site Actions" I was able to delete some of my Content Types and Custom Columns.
    - But I was unable to delete some of them..
    - Checked and deleted my WorkFlow tasks (TASKS List) and WorkFlow History  - With the help of SP Designer
    - Then cleaned up my site Recycle Bin and Site Collection Recycle Bin
    - IISReset /noforce on the server
    - Went back to my "Site Action", started with "Site Content Type" and there you go... deleted all of my unwanted CT and in
    the "Site Columns" option I was able to remove my unwanted columns. 

    I hope this would help some of you.


    Ricardo R Franco
    Lisboa - Portugal
    Friday, January 15, 2010 4:15 PM
  • This post is for 2007 but I had the same problem in 2010. Please see my post at http://social.technet.microsoft.com/Forums/en-US/sharepoint2010general/thread/a36ff299-8934-49e6-b55f-f78bc1a449c6 to how to avoid this problem.
    Wednesday, June 15, 2011 3:11 PM