Sql-server – How to skip rows that I’ve already imported

sql serversql-server-2008

I've previously used the SQL Server 2008 R2 "import data" wizard to import an Excel file into my database.

Now I'm trying to import more Excel sheets that may contain the same data that was previously imported.

How can I import these Excel sheets to the same database, while skipping the rows from Excel that already exist in the database?

Best Answer

2008 supports except. Import the excel data into a different table--mytemptable--then

INSERT INTO mymaintable
SELECT * from mytemptable
EXCEPT 
SELECT * from mymaintable;

Then you can get rid of mytemptable (or whatever you want to call it).