我正在尝试使用 Microsoft SQL Server Management Studio (select * from openquery ([PROALPHA], 'select Date来自 PAVAR.PUB.UVT_DatesOfVersionsBOPos')
不幸的是,我收到以下错误消息:
The OLE DB provider "MSDASQL" for the connection server "PROALPHA" has the message "[DataDirect] [ODBC Progress OpenEdge Wire Protocol driver] [OPENEDGE] Syntax error in SQL statement at or about" Date from PAVAR.PUB.UVT_DatesOfVersionsB "( 10713) ".
Msg 7321, Level 16, State 2, Line 1
Failed to prepare the select date from PAVAR.PUB.UVT_DatesOfVersionsBOPos query to run for the OLE DB provider "MSDASQL" for the linked server "PROALPHA".
我假设 SQL 将日期字段解释为日期函数,因此显示错误。
你们中有人知道正确的语法以便我可以获取该字段吗?
最佳答案
语法错误是因为 DATE 是 OpenEdge SQL 中的保留字。仅当用双引号分隔关键字时,才可以在 SQL 语句中使用关键字作为标识符。
示例 1:这会生成您所描述的语法错误
SQLExplorer>select date from pub.cust1;
=== SQL Exception 1 ===
SQLState=HY000
ErrorCode=-210056
[DataDirect][OpenEdge JDBC Driver][OpenEdge] Syntax error in SQL statement at or about "date from pub.cust1" (10713)
示例 2:这在我们用双引号分隔保留字时起作用
SQLExplorer>select "date" from pub.cust1;
date
----------
关于sql - 在 OpenEdge 中选择字段日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63226694/