Avatar of Mehawitchi
Mehawitchi
 asked on

How To Insert Non-Duplicate Rows into SQL Table

Hello Experts,

I have an SSIS package that reads from Excel File and loads the data into a SQL table.

The SQL table has a Unique constraint comprised of three columns (Category, Genre and SubGenre), so when I attempt to load the SQL table from the Excel table, the entire insert statement is terminated because some of the records in the Excel table already exist in the SQL table.

I need to build a query or (some logic) to extract only the rows that don't exist in the SQL table. Something along the following:

Insert Into Table2 (Col1, Col2, Col3)
(SELECT Col1, Col2, Col3 FROM Table1 WHERE NOT EXIST in Table2)

Many thanks for your help,
Hani
Microsoft SQL ServerSSISSQL

Avatar of undefined
Last Comment
Mehawitchi

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Vitor Montalvão

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Guy Hengel [angelIII / a3]

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Mehawitchi

ASKER
Thank you Vitor / Guy.

Worked like charm
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck