Click here to Skip to main content
16,015,559 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have the following code:

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];


Runs great in my SQL server, but in access no go.
ERROR: [Microsoft][ODBC Microsoft Access Driver] Syntax error in JOIN operation. Error Code: -3510

Ive even tried adding the extra (( for joins, same error.

Please any help would be appreciated.
Posted
Comments
Mehdi Gholam 19-Oct-14 2:24am    
Try removing the "dbo." prefix.
Frans.Hendrik 19-Oct-14 2:48am    
Still gives me the same error.
Maciej Los 19-Oct-14 5:19am    
What version of MS Access database?
What OS version where SQL server is placed (Win32 or Win64)?
What '' does before IN statement?
Is MS SQL server defined a system or user ODBC datasource?
Frans.Hendrik 19-Oct-14 6:15am    
Well access 2013. Both 64bit.
I believe that this isn't the problem due to the query running fine without any joins, as well as the '' before the IN statement. The code is run in vb.net, the '' is just placeholder within vb.net.

The SQL server run on the same machine. Hence its working fine with just normal query to get data. My problem is with the joins. It uses the OBDC driver for SQL Server. That is fine since a simple query runs normal
Kornfeld Eliyahu Peter 19-Oct-14 5:47am    
Why all those parentheses before FROM and after every join - you need no nested joins here (and in any case the syntax is wrong). Remove them!

1 solution

Finally, after all these comments, i'd suggest to use simple SELECT statement rather than inserting data.

As is described here: INNER JOIN Operation (Microsoft Access SQL)[^], the proper sql query should look like:
SQL
FROM dbo.vw_TransWIPGeneric AS [t]
INNER JOIN (dbo.EntityConnections AS [c]) INNER JOIN dbo.Entities AS [g] ON c.EntityId = [t].EntityId)
ON c.GroupId = [t].EntityId
''IN [ODBC;Driver={SQL Server};Server=FRANSWINDOWS10\SQLEXPRESS;Database=D:\USERS\FRANS\DOCUMENTS\WORK\SQL DATABASE\CATC14.MDF;Trusted_Connection=yes];


BUT(!) i need to warn you: there is no relationship between [g] and [c].

By The Way: MS Access database engine likes several parentheses (see comments).

Here is another suggestion: INNER JOIN Operation[^]
SQL
SELECT fields
FROM table1 INNER JOIN
(table2 INNER JOIN [( ]table3
[INNER JOIN [( ]tablex [INNER JOIN ...)]
ON table3.field3compoprtablex.fieldx)]
ON table2.field2compoprtable3.field3)
ON table1.field1compoprtable2.field2;


I'm not sure which one is good. I'm not using MS Access database yet.

Let me know if it was helpful to you.
 
Share this answer
 
Comments
Frans.Hendrik 25-Oct-14 1:26am    
Would you be able to connect on teamviewer to assist?
Maciej Los 25-Oct-14 8:06am    
Yeah, but i can't define when i'll have a free time. Maybe on sunday between 9AM and 11AM (Central Europe time). Is it OK?
Frans.Hendrik 26-Oct-14 1:08am    
GREAT!
Maciej Los 26-Oct-14 5:09am    
I need your ID ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900