简体   繁体   English

如何在VBA访问中使用SQL MERGE语句?

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

I have been trying to use the MERGE statement in my Access application. 我一直试图在Access应用程序中使用MERGE语句。 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. 我收到错误3078:Microsoft Office Access数据库引擎找不到输入表或查询“ MERGE TargeTable AS Sourceing Table as S ...”,请确保它存在并且其名称拼写正确。

Help will be appreciated. 帮助将不胜感激。

Access does not support MERGE. 访问不支持MERGE。 That construct exists in T-SQL (SQL Server) and other SQL dialects, but not in Access SQL. 该构造存在于T-SQL(SQL Server)和其他SQL方言中,但在Access SQL中不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM