SQL Server 2005.
I'm adding Foreign Key constraints to the database of an application that allegedly didn't need them. Naturally, the data has become unreliable and there are orphaned entries in the foreign key field.
Setup:
Two tables, TableUser and TableOrder.
TableUser has Primary Key 'UserID', and TableOrder has Foreign Key 'UserID'.
How do I find the rows where TableOrder.UserID has no matching entry in TableUser.UserID?
For example, TableOrder.UserID has a value of 250, but there is no matching TableUser.UserID key for 250.