Page 1 of 1

SELECT * FROM external_db WHERE order_id NOT IN internal_db

Posted: Thu Dec 20, 2007 11:03 am
by Luke
I need to import orders from an external database routinely. Every time somebody clicks "Synchronize DBs" I want to grab all order_ids that I don't already have? How should I go about this? It seems like an easy task... my first instinct was to just select all ids from my db and perform this query:

Code: Select all

SELECT * FROM external_db WHERE order_id NOT IN (@internal_ids)
I'm just wondering if there isn't a better way. Thanks! :)

Posted: Fri Dec 21, 2007 8:29 am
by feyd
Useful posts has a thread on selecting stuff in one table that isn't in another.

Re: SELECT * FROM external_db WHERE order_id NOT IN internal_db

Posted: Mon Jan 14, 2008 5:17 pm
by emmbec
If your database is in SQL Server you could use a DTS, I don't know if it is more efficient, but it is very easy to do.