我查看了有关此主题的几篇帖子,但未能看到解决此错误的问题。我已经链接了我想要包含在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))
答案 0 :(得分: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)