1

我查看了有关此主题的几篇帖子,但无法解决此错误。我已经链接了我试图包含在 SQL 2008 中的 WHERE 子句中的服务器。我能够在没有 WHERE 子句的情况下成功执行查询。我确定我忽略了一些东西,只是需要一些建议。多部分标识符的消息位于 WHERE 子句中的这一行。

LAWNURSEDB.NGDemo.dbo.EXPORT_DIRECTTIME.SocialSecurityNumber

SELECT     dbo.VP_PUNCHORIGIN.PERSONNUM, EXPORT_DIRECTTIME_1.SocialSecurityNumber,         dbo.VP_PUNCHORIGIN.PERSONFULLNAME
FROM         dbo.VP_PUNCHORIGIN INNER JOIN
                  LAWNURSEDB.NGDemo.dbo.EXPORT_DIRECTTIME AS EXPORT_DIRECTTIME_1 ON 
                  dbo.VP_PUNCHORIGIN.PERSONNUM = EXPORT_DIRECTTIME_1.SocialSecurityNumber
WHERE     (dbo.VP_PUNCHORIGIN.PERSONNUM NOT IN
                      (SELECT     LAWNURSEDB.NGDemo.dbo.EXPORT_DIRECTTIME.SocialSecurityNumber AS Expr1
                        FROM          LAWNURSEDB.NGDemo.dbo.EXPORT_DIRECTTIME AS EXPORT_DIRECTTIME_1))
4

1 回答 1

2

您在子句子查询中使用别名WHERE但不引用它:

SELECT p.PERSONNUM, 
    EXPORT_DIRECTTIME_1.SocialSecurityNumber,         
    p.PERSONFULLNAME
FROM dbo.VP_PUNCHORIGIN p
INNER JOIN LAWNURSEDB.NGDemo.dbo.EXPORT_DIRECTTIME AS EXPORT_DIRECTTIME_1 
    ON p.PERSONNUM = EXPORT_DIRECTTIME_1.SocialSecurityNumber
WHERE p.PERSONNUM 
         NOT IN (SELECT EXPORT_DIRECTTIME_2.SocialSecurityNumber 
                 FROM LAWNURSEDB.NGDemo.dbo.EXPORT_DIRECTTIME AS EXPORT_DIRECTTIME_2)
于 2013-01-10T15:54:45.623 回答