SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an requirement of fetching bulk data from sharepoint list using SPquery. Here is the code

DataTable dt=new DataTable();
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope=\"SiteCollection\"";
query.Query = "<Where><Eq><FieldRef Name='Title'><Value Type='Text'>s</Value></Eq></Where>";
query.ViewFields = "<FieldRef Name='Title'>";
query.ViewFieldsOnly = true;
query.QueryThrottleMode = SPQueryThrottleOption.Strict;
splist.EnableThrottling = false;
query.RowLimit = 2000;
                            SPListItemCollection myItems = splist.GetItems(query);
                            if (dt == null || dt.Rows.Count <= 0)
                                dt = myItems.GetDataTable();
                            query.ListItemCollectionPosition = myItems.ListItemCollectionPosition;
                        while (query.ListItemCollectionPosition != null);

If I didn't set splist.EnableThrottling = false I am unable to retrieve bulk data from sharepoint list. Programatically If I have set the splist.EnableThrottling = false I am getting Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack error,I have gone through the msdn article property requires Farm Admin Permission.

So how could I retrieve bulk data without using splist.enablethrottling property.Could anyone help me to solve this issue ?

share|improve this question
up vote 2 down vote accepted

SharePoint Server 2010 provides a new class named ContentIterator that you can use to query lists without hitting these limits. You should consider using this class if you need to run a query that will return more than 5,000 rows of data.

share|improve this answer
Thanks for your reply. – Ramalingam Dec 27 '11 at 6:36
Thanks you so much! – Serhiy Mar 20 '13 at 10:59

You can use cycle with paging. Get 1000 items and add it to DataTable while query.ListItemCollectionPosition isn't null.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.