Content Type Limits in MOSS

Someone asked me an interesting question recently;

“Is there a limit on the number of content types that one can add to a list or library ?”

This isn’t something I’d ever seen documented, so I started looking for the answer. Eventually, I found some comments about a post by Martin Kearn at this page; http://blogs.msdn.com/martinkearn/archive/2006/03/27/561809.aspx

His comment answered basically the same question, and he stated “there is no hard limit in terms of the number you can have. The only hard limit in the product is that the total size of all content type schema on the list cannot exceed 2GB”.

I was glad to finally have some sort of answer, but two things worried me;
1. I don’t like taking such answers at face value without verifying the facts myself
2. His comment addressed MOSS 2007 beta 2, rather than the current released version

So, how to verify this myself? I didn’t fancy creating 2Gb of Content Type Schema to load into a list, there had to be a better way! Then I got one of those hunches, it might not be a hard-coded limit, maybe it was SQL Server inspired?

I popped open a copy of a MOSS 2007 Content Database on my sandbox environment (‘cause we’d never do that on a Production environment! Right kids?!). The AllLists table seemed to be winking at me straight away, and sure enough it contained a column called tp_ContentTypes. Within that column I could see the Content Type schema for a particular list there in plain text. The data type of the column was ntext. ‘Eureka!’ as a clever naked Greek once famously shouted. NText is 2 gigabytes in size, and that’s where the limit comes from.

There could be some limits in the source code of MOSS as well, but they’d not be too easy to track down! I feel fairly satisfied with the answer.

As for the lack of documentation on the topic, well, I guess this blog post will have to do!