Could not add the table (

亡梦爱人 提交于 2019-12-02 03:51:18

The issue with MSQuery is that it attempts to display your query graphically in it's design view, this works OK for simple queries but not for complex queries which usually generates the could not add table message. The way I found around this is to treat your query as one big sub query inside a wrapper query, this forces MSQuery to give up the design view and work as pure SQL text.

Another issue might be that for one table you have the full path but not the others, is it correct for the table you have included it and does it need to be used on the other tables.

Here is an example of the changes I think you should make:

SELECT * FROM (
SELECT bcs.BomReference
  ,bcs.DateTimeCosted
  ,bcs.TotalCost
  ,BomBuildProduct.StockDescription
FROM 
  (SELECT BomReference
     ,Max(DateTimeCosted) AS MaxDate
   FROM NDM_Sage200.dbo.BomCostSession BomCostSession
   GROUP BY BomReference) AS ldc
INNER JOIN NDM_Sage200.dbo.BomCostSession AS bcs ON bcs.BomReference = ldc.BomReference
  AND bcs.DateTimeCosted = ldc.MaxDate
INNER JOIN NDM_Sage200.dbo.BomBuildPackage ON BomCostSession.BomBuildPackageID = BomBuildPackage.BomBuildPackageID
INNER JOIN NDM_Sage200.dbo.BomBuildProduct ON BomBuildPackage.BomRecordID = BomBuildProduct.BomRecordID) x
ORDER BY BomReference
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!