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 know you can backup site collections with stsadm -o backup, and you can backup sites with stsadm -o export. But what's the best way to copy a list. I've tried to use the save as a list template and include content, but not all the columns came across. For example I had a lookup to another column in the same list but the data was totally messed up. only about 10% of the values were correct. I heard this is supposed to be available in 2010, but what's the best way to copy a list in 2007.

share|improve this question
add comment

5 Answers 5

up vote 6 down vote accepted

I used the stsadm extensions to be able to import and export lists and libraries.

share|improve this answer
    
Can you give me more info? I'm in the Air Force at work and the link you posted is blocked, as a lot of blogs and sites categorized as none are. –  Bob Dec 4 '09 at 16:26
    
It's a set of extensions for stsadm which allows you to export and import lists and libraries using the migration apis. –  Steve Lineberry Dec 4 '09 at 19:54
add comment

You have already tried the best way, Save as Template and add it to the New Site. And to make the Look Up field work refer to this article that provides an alternate to do it.

Also one another way if wanted to do is to Create a List Template and Deploy it as a Feature using WSP solution, but if you are going to use this List only Once then you don't need to create a List Template. One Another item to note in the List Template is you will have to Hand code the XML with the Data contained in the list. Here is a nice article on how to create a List Template.

share|improve this answer
    
I'll give that a shot. Will this also work with large lists or libraries ? I've heard that's another limitation. –  Bob Dec 4 '09 at 5:08
add comment

goign to Site Settings -> Site Content and Structure, I created a new list in the new site with it's default list structure. Then I went to the old list and selected all the data rows then copied them to the new list. SharePoint copied the data and the list structure to the new list and made the new list look and work just like the old list. I was very happy.

share|improve this answer
add comment

Using the content deployment wizard (http://spdeploymentwizard.codeplex.com/ ), you can export a specific List or document library and then import it to another site.

This is a graphical wizard that displays all site content in a tree like view then you can select what lists or libraries to export. You can then use it again to import whatever you exported to the new site.

share|improve this answer
add comment

I am not sure what is the best way, but I did it using a Console App, with following code,

        SPList myDestinationList = web1.Lists[destinationlistName];
        SPList mySourceList = web2.Lists[Form1.OldListName];
        SPQuery mySourceListQuery = new SPQuery();

        mySourceListQuery.Query =

            "<OrderBy><FieldRef Name='a' />" +
                     "<FieldRef Name='b' />" +
            "</OrderBy>";

        SPListItemCollection mySourceItemColl = mySourceList.GetItems(mySourceListQuery);
        foreach (SPListItem mySourceListItem in mySourceItemColl)
        {
            SPListItem myDestinationListItem = myDestinationList.Items.Add();

            if (mySourceListItem["a"] != null)
                myDestinationListItem["a"] = mySourceListItem["Title"];

            if (mySourceListItem["b"] != null)
                myDestinationListItem["b"] = mySourceListItem["Location"];


            web1.AllowUnsafeUpdates = true;
            web2.AllowUnsafeUpdates = true;
            myDestinationListItem.Update();
            web1.AllowUnsafeUpdates = false;
            web1.AllowUnsafeUpdates = false;
        }

It did worked with Custom columns and lookup columns as well.

share|improve this answer
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.