DTS export help

  • Hi,

    I have the following database:

    CREATE TABLE [dbo].[People] (

     [IdPeople] [int] NOT NULL ,

     [Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [Lastname] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

    ) ON [PRIMARY]

    I made a DTS package to export this data to another server, when I run the DTS package it export all the records to the destination server but I got an error: Violation of PRIMARY KEY constaint, this is due to the DTS is exporting record that already exist in the destination db, so what I want to do is:

    if dts export a record that already exist on the destination db, what I want to do is make an update this record and insert the new ones.

    It is possible to do this in a DTS package?

    thanks,

    geykel

  • Hi,

    maybe the Data Driven Query Task will do that for you. I'm not sure cause I didn't use it before.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dtssql/dts_elemtsk1_9w2z.asp

    jan

  • One possible solution: 

    Rather than inserting directly to the table, create a table on the destination with the same structure and import to that table.  You can think of this table as a temp table, but since DTS doesn't work with temp tables, you have to have a permanent table.  You can either truncate the table each time the package starts or create it each time.  Once you have the data in a temp table on the target server, you can add a Exec SQL step that will process the loaded data from the "temp" table to the "live" table using standard sql syntax.

    Hope that helps!

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

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