Kambiz
Kambiz

Reputation: 321

How can I use a SQL MERGE Statement in VBA access?

I have been trying to use the MERGE statement in my Access application. When I use the following code (simplified for readability):

dim strSqlMerge as string
strSqlMerge = "MERGE TargeTable AS T USING SourceTable as S " & _
" ON T.PrimaryKeyColumn = S.PrimaryKeyColumn " & _
" WHEN MATCHED AND PrimaryKeyColumn = 'hardcodedvalue' THEN " & _
" UPDATE SET T.Column1 = S.Column1, T.Column2 = S.Column2, ..."

Currentdb.Execute strSqlMerge

I get the error 3078: The Microsoft Office Access database engine cannot find the input table or query 'MERGE TargeTable AS T USING SourceTable as S ...' Make sure it exists and that its name is spelled correctly.

Help will be appreciated.

Upvotes: 0

Views: 1655

Answers (1)

Cetin Basoz
Cetin Basoz

Reputation: 23797

Access does not support MERGE. That construct exists in T-SQL (SQL Server) and other SQL dialects, but not in Access SQL.

Upvotes: 1

Related Questions