Link to home
Create AccountLog in
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
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Mehawitchi
Mehawitchi

ASKER

Thank you Vitor / Guy.

Worked like charm