moving data between tables of similar structure

  • I want to move data from one large table to smaller tables of similar structure, e.g. the same field names / attributes / constaints. Is there any book, or any guide on how to do this? What is this topic called in SQL Speak? Thx. Tim.

  • if it's the same structure, write a query to get the data you want to move, i.e.,

    select Col1, Col2, Col3

    from BigTable

    where Col1 >10

    Once you have your queries, then do a

    insert SmallTable

    select...

    with you select statement. Repeat for each table.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • I don't think there's a topic on this in BOL.

    It may be worth batching up the scan of the large table into smaller chunks avoiding a large rollback if something goes wrong i.e. WHERE PK < @SomeValue. Incrementing @SomeValue on each itteration until the table is completely copied/moved.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply