Thursday, January 15, 2009

Content Type is still in use

Despite the fact that no files has the a specified content type I still get the error content type is still in use when I try to delete the content type.

I came across this blog that stated that you also needed to look into previous versions of the files as well as files hidden.

Despite the fact that I have done this I cannot delete the ContentType.

I therefore looked into the SQL database in the AllUserData table in the Content database with the following SQL
FROM AllUserData
WHERE (tp_DirName LIKE '%')
AND ((tp_ContentType = ''))
ORDER BY tp_DirName

Then I got a list of files using the content type.

The main issue now is that I cannot figure out how to get rid of the content type from these files. Ideas very much appreciated.

I have
  1. Checked in documents
  2. Published them all - i.e. major version
  3. Previous versions has been deleted
  4. Emptied recycle bin
  5. Ensured the content type I wish to delete is not default content type (apart from the fact that SharePoint suggest it to be the new default when uploading documents - which is strange. Maybe this is the reason?)

So what do I do?

Even if I DELETE the files and REMOVE them from recycle bin they still appear in the SQL search. No wonder I cannot get rid of the content type!

Even if I go through all files in the Document Library and explicitly set

oFile.Item("ContentType") = <...>

I cannot DELETE the content type afterwards. Very strange.


Lisa said...

Make sure there are no workflows running on an item using the Content Type you want to delete.

Anonymous said...

I'm in the same situation and found the SQL records using the query that's posted. Did you ever find a solution to this issue? I'm at the point of deleting the SQL records but I don't know if they may exist in other db tables. Any help will be greatly appreciated. Bryan Roberton (

Morten Marquard said...

Hi Bryan,
You MUST delete all old versions with the old content type in order to have it released from the database. However, even in this sitaution I have not managed to get all objects released.

I tried to change the database by modifying the content class of the object - I didn't delete it (didn't dare to). Unfortunately it didn't help. So I reestablised the solution and created a new document library without the problem.


tripwire said...

Did you ever find a solution to this? We're in the same boat and this is driving me nuts!

Morten Marquard said...

Nope - never got it working.

Well - export all documents. Delete the document library, import all documents again. Voila.

tripwire said...

Thanks Morten. Not really the solution I was looking for though. :)

Kiran said...

I had the same issue. I ran the following query to findout the items using the content type

FROM AllUserData
WHERE (tp_DirName LIKE '%')
AND ((tp_ContentType = '') and tp_ListId='')
ORDER BY tp_DirName

I found some items still using content type. So decided to delete these item from table.

FROM AllUserData
WHERE (tp_DirName LIKE '%')
AND ((tp_ContentType = '') and tp_ListId='')

and guess what!!!!! It worked. I was able to delete content type.

junkyardforg said...

I ran into this same problem and had to delete all the documents from the library that were using that content type... and it only took me two days to figure that out!


Anonymous said...

If you're using a content type on a workflow, then that content type will be listed in the Tasks list associated with the workflow. It must be deleted from there first, then it's able to be deleted from the site.

Anonymous said...

I ran into the same situation and found that contentapproval was enabled on the list. Some items where not approved so the unapproved items still held to the previous contenttype.

Anonymous said...

If this is for SharePoint 2010 then check your recycle bins to make sure there are no lists using the content type that have been deleted.

I came across this issue a wee while back!

Mauro Masucci said...

You need to disassociate the content type from the list you were using it in. If its still associated to the list then it will be "in use"

David Lozzi said...

I had the same issue, deleted the library and the content type was still in use. I cleared the recycle bin, end user recycle bin and site collection recycle bin and then it let me delete it

Morten Marquard said...

Most of the time it works - but sometimes SharePoint act strange as described here.

I simply didn't manage to get the record removed using SharePoint API - so had to remove it using SQL - WHICH IS DANGEROUS AND NOT SUPPORTED BY MICROSOFT.

Lex said...

This worked for me:

Use the following command to get a list of all solutions that are being deployed.
stsadm -o enumdeployments

Use the JobId GUID that comes back from this e.g. Deployment JobId="e99b7304-cfc0-419a-a3f2-18ca5193c838"

Cancel the "stuck" deployment (in "Deploying" status" with the following command
stsadm -o canceldeployment -id e99b7304-cfc0-419a-a3f2-18ca5193c838

Delete the stuck solution once and for all with
stsdm -o deletesolution -name mysolution.wsp -override
Redeploy your solution.


tripwire said...

How in God's name is a stuck solution even remotely relevant to removing a content type that is in use??

Anonymous said...

I ended up deleting my entire site collection, and then recreate it.

Lucky for me I was in a dev environment, and had nothing important in it.

I had a developed a feature that added a content type. My deactivate event didn't manage to delete the content type, and manually deleting throw the error "still in use", even while I never (!) even used the content type in a list or anything.

Removing the solution didn't help, it was still in use...

But that's what you learn when developing in SharePoint: it will always fail somewhere for some nonsense reason that only Microsoft knows, and before you know it you destroyed your entire environment without any plausible reason.

Thank you Microsoft for all the nonsense that we developers come across when developing in SharePoint! Without you my days would be oh so boring...

Anonymous said...

Should these same queries work on a SharePoint 2010 database? I keep getting errors that state invalid columns.
Msg 207, Level 16, State 1, Line 3
Invalid column name 'tp_DirName'.
Msg 207, Level 16, State 1, Line 4
Invalid column name 'tp_ContentType'.
Msg 207, Level 16, State 1, Line 5
Invalid column name 'tp_DirName'.

Anonymous said...

I encountered the same issue. I was able to finally remove the content type by not making it visible in the "Content Type Order" setting (uncheck the Visible checkbox). Once that was done, I was able to delete the unused content type.

JW said...

i was able to work around this by going to the library using the content types and deleting from there then going to site contenty types gallery to delete.

Matt said...

You should check out the following two sites. Synopsis: Use SharePoint Manager to locate the content type then ensure you have deleted them from all the recycle bins.



Francois Souyri said...

Struggled in same issue as well.
Eventually this is my fix :
- Empty you own Recycle Bin
- then the Site Collection Recycle Bin http://sharepoint/_layouts/AdminRecycleBin.aspx
that's not it, now check both views:

Select a View
End user Recycle Bin items
Deleted from end user Recycle Bin
and make sure they are both Empty.

This did the trick to me and I was able to delete my Infopath Admin Signed form Content Type.