Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to clear the data contained in a list programmatically.

I know I can iterate through every single item to delete it, but that takes forever.

Any suggestion?

(I'm with the client object model by the way)

Thanks

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

Fastest method is to delete list and then recreate it from scratch trough UI. However in many scenarios this is not possible.

If you cannot use server object model to do deletion next best thing is to use Lists.UpdateListItems webservice and preform batch deletion.

Take a look at this SO question and accepted answer:

How to Delete all the Items from SharePoint List without iteration using SharePoint Webservice

share|improve this answer
add comment

As I know it allways was a problem to clear SharePoint list. I did it that way - I created a list template from my target list and then I was able to delete list and quickly recreate it again. As I remember it was a quite acceptable solution. But I did it from server side object model.

share|improve this answer
    
Recreating the list is a fairly expensive operation (since you get db hits for deleting the list, recreating it, and adding the items again). Also the list will have a new GUID which might mess some things up (for example if you have some web parts using GUIDs, third party apps, workflows, etc.). Best to use the UpdateListItems batch method above. –  Bil Simser Feb 9 '12 at 2:51
add comment

Your Answer

 
discard

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.