Fix: Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries

Recently, I faced this issue when user open aspx page in SharePoint 2007 page library. The error message is not really helpful and if you look on SharePoint log, it also provide you with same error message “Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries”.

Issue
SQLNestedTooDeeply

Further googling on the issue, I found other people faced the same issue and it feels related to mine. You could look in here. From that resources, they specified the root of the issue is Workflow History list.

“Workflow History first. The Workflow History list is a hidden list which does exactly what it says on the tin. Items are created each time a workflow runs. It turns out that items in the Workflow History list have a time-to-live and that time is 60 days. That means that any item in the list will automatically be deleted after 60 days. With roughly a 200 item limit before you hit trouble that means about 3 workflows per list item per day is your maximum.”

Resolution

  • Delete items in Workflow History list. You could found simple console application for this here.
  • Limit document versions. I deleted old version history and only keep the last 5 major versions.
Advertisements

Tagged: , , , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: