2014-10-11 177 views
0

下面的查詢不斷給我的錯誤:SQL查詢來訪問查詢

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服務器運行它運行得很好。

ERROR: [Microsoft][ODBC Microsoft Access Driver] Syntax error in JOIN operation. Error Code: -3510

回答

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 
+0

這似乎並沒有工作。我必須添加括號,因爲這是MS Access。 – user2459813 2014-10-12 11:39:13