Restore Data to Tables using DTS

  • How do i create a DTS package to restore data through a csv file, while i should also compare the existing data to overwrite and not delete any other data(new not within the file) from the existing table

    hope somebody can help me on this issue. it is quite urgent

    regards

    roopa

  • Hi, put the dts data in a temp table. Write some sp's to update from the temp table to the real table.

  • Jan's method is the one I'd use, however I'd add a proviso that you either make sure you either drop the temporary table or truncate it each time before you run the DTS. Bitter experience I'm afraid nothing like populating your temporary table with several duplicate versions of the data and then wondering why your SP is still running at midnight to nmake you wary.

    I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961


    I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961

  • Hi

    how do i create an sp to write into a table while comparing all the data from temp table to the real table in database.

    do we use cursors to open the records and use while loops in the sp

    thanks in advance

    roopa

  • no cursors needed.

    Use an UPDATE to update data.

    update realtable

    set cola = b.cola

    , colb = b.colb

    ...

    from temptable b

    where realtable.pkcol = b.pkcol

    Then use the same join to issue a delete against the temp table. This will remove matching data. Everything left is new, so insert it.

    Steve Jones

    steve@dkranch.net

  • Thanks a lot for your suggestion

    roopa

Viewing 6 posts - 1 through 5 (of 5 total)

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