验证MS Access中的错误导入数据

时间:2012-02-29 12:59:45

标签: sql ms-access

这种情况很典型。用户要求我将电子表格导入表格 - Mastertable。

Mastertable的PK为acct,FK为ProviderID。

导入进展不佳,大约10%的记录因严重违规而丢失。我认为这是由于指定了一个不存在的providerID。

有没有办法可以找出哪些提供商ID不好?我可以导入一个新表 - “MasterTableNew”,但当我选择这样的时候:

SELECT acct FROM MastertableNew 
WHERE NOT EXIST (
   SELECT Mastertable.acct 
   FROM Mastertable 
   INNER JOIN MastertableNew 
   ON Mastertable.acct = MastertableNew.acct)

它变成空白 - 我希望看到MastertableNew中存在Mastertable中不存在的行。

1 个答案:

答案 0 :(得分:1)

怎么样:

SELECT acct FROM MastertableNew 
LEFT JOIN Mastertable ON MastertableNew.acct = Mastertable.acct
WHERE Mastertable.acct Is Null