SQL查询访问查询

时间:2014-10-11 18:59:11

标签: sql sql-server stored-procedures acc

以下查询不断给我错误:

INSERT INTO [tableFinalData] (ClientGroupCode, WorkActivity, SubProj, ClientCode, Client
                           , ProjectYear, StaffCode, ProjectCode, Hours, Rate, Amount, BillingStatus) 
SELECT g.EntityNo AS [GroupName]
     , dbo.vw_TransWIPGeneric.WorkCodeNo
     , dbo.vw_TransWIPGeneric.WorkCodeName
     , dbo.vw_TransWIPGeneric.EntityNo
     , dbo.vw_TransWIPGeneric.EntityName
     , dbo.vw_TransWIPGeneric.ProjectTypeYearNo
     , dbo.vw_TransWIPGeneric.EmployeeNo
     , dbo.vw_TransWIPGeneric.SubprojectTypeNo
     , dbo.vw_TransWIPGeneric.Quantity
     , dbo.vw_TransWIPGeneric.Rate
     , dbo.vw_TransWIPGeneric.Amount
     , dbo.vw_TransWIPGeneric.BillingStatus 
FROM ((dbo.vw_TransWIPGeneric 
INNER JOIN dbo.EntityConnections AS [c] ON c.EntityId = dbo.vw_TransWIPGeneric.EntityId)
INNER JOIN dbo.Entities AS [g] ON c.GroupId = dbo.vw_TransWIPGeneric.EntityId)
''IN [ODBC;Driver={SQL Server};Server=FRANSWINDOWS10\SQLEXPRESS;Database=D:\USERS\FRANS\DOCUMENTS\WORK\SQL DATABASE\CATC14.MDF;Trusted_Connection=yes];

当我在SQL server中运行它时运行正常。

  

错误:[Microsoft] [ODBC Microsoft Access驱动程序] JOIN中的语法错误   操作。错误代码:-3510

1 个答案:

答案 0 :(得分:0)

我相信你必须有很多括号。添加别名:

FROM ((dbo.vw_TransWIPGeneric 
INNER JOIN dbo.EntityConnections AS [c] ON c.EntityId = dbo.vw_TransWIPGeneric.EntityId)
INNER JOIN dbo.Entities AS [g] ON c.GroupId = dbo.vw_TransWIPGeneric.EntityId) t

或摆脱所有这些:

FROM dbo.vw_TransWIPGeneric 
INNER JOIN dbo.EntityConnections AS [c] ON c.EntityId = dbo.vw_TransWIPGeneric.EntityId
INNER JOIN dbo.Entities AS [g] ON c.GroupId = dbo.vw_TransWIPGeneric.EntityId