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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked like charm