Import to SQL Server w/o duplicates

Results 1 to 2 of 2

Thread: Import to SQL Server w/o duplicates

  1. #1
    Join Date
    Dec 1969
    Posts
    158

    Default Import to SQL Server w/o duplicates

    Hi. I&#039;m trying to figure out an easy way to import some data into SQL Server that will ignore any values in a primary key column that are already present in the destination table. I&#039;ve been working with the Import feature in SQL Server Client Tools, and it works fine if there are no duplicate keys, but it fails if there are duplicates. It would be nice to just set an option in the SQL Server Import wizard to ignore duplicates, but I can&#039;t find such an option. What would be a good way to go about this?<BR><BR>Thanks!<BR>Corey

  2. #2
    Join Date
    Dec 1969
    Posts
    3,961

    Default RE: Import to SQL Server w/o duplicates

    You could create a linked server to the source import table, then use a INSERT SELECT... statement to import the data. You could then use WHERE Id NOT IN (Select Distinct id FROM DestinationTbl) to ensure you&#039;re not importing an Id that already exists.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •