What is the best way to partially import data from another database

  • I am trying to import data from another SQL database residing on different server, I would like to import only 6 months worth of data, is there any good way to do this?

    Thanks for all help ..

     

     

     

  • Insert into dbo.LocalTable (col1, col2) Select col1, col2 from LinkedServerName.DbName.dbo.TableName where DateDate between @Start and @End

    Look up linked servers in books online.

  • You can create a view which has the same column list as your source table and a WHERE clause:

    create view v_xxx

    ..

    as

    select

    ..

    from <source table>

    where <column> >= dateadd(day, -180, getdate())

    go

     

    Then, you can BCP out data from view, then BCP in data into your target table

     

    -- Peter Lo

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

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