Hi I have re-added a foreign key relationship to a table in order to do so I had to abandon checking data on creation. I presume some parent(Company) objects have been deleted and I want to find the orphaned(Division) records. How would I find an row where the foreign key does not exist in the primary table?
This is what I was thinking but am struggling with the where clause.
SELECT tb_Division.DivisionName,
tb_Division.DivisionCompanyID
FROM tb_Division
LEFT OUTER JOIN tb_Company ON tb_Division.DivisionCompanyID = tb_Company.CompanyID
WHERE (tb_Company.CompanyID = NULL
OR 'doesn't exist in tb_Company')
Any pointers much appreciated.