简体   繁体   English

链接服务器“(null)”的 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0”返回消息“JOIN 操作中的语法错误”。

[英]OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)” returned message “Syntax error in JOIN operation.”

I am getting this annoying error, but the thing is that I do not use any JOIN operation in my query.我收到了这个烦人的错误,但问题是我没有在查询中使用任何 JOIN 操作。 Here is the snippet:这是片段:

   ('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=C:\Users\tcmnoc\Desktop\Test.xlsx;','SELECT * FROM ([TradeCloud].[dbo].[Adminlist]')
   Select * from [TradeCloud].[dbo].[Adminlist]```

Assuming your snippet derives from an OPENROWSET query, you are conflating data sources where you attempt to reference an SQL Server table inside an Excel connection.假设您的代码段来自OPENROWSET查询,您正在合并数据源,您试图在 Excel 连接中引用 SQL Server 表。 When connecting to an Excel workbook as a data source, you can only reference Excel worksheets, not SQL Server tables.连接到 Excel 工作簿作为数据源时,您只能引用 Excel 工作表,而不能引用 SQL Server 表。

Therefore, this source is not recognizable: [TradeCloud].[dbo].[Adminlist] (correcting the opening parenthesis with square bracket).因此,无法识别此来源: [TradeCloud].[dbo].[Adminlist] (用方括号更正[TradeCloud].[dbo].[Adminlist]括号)。 Instead, connect to an actual Excel worksheet within the workbook connection, placing the named reference outside of the connection string.相反,连接到工作簿连接内的实际 Excel 工作表,将命名引用置于连接字符串之外。 Below query (after you adjust mySheet should work to retrieve Excel-only data):下面的查询(在您调整mySheet 后应该可以检索仅限 Excel 的数据):

SELECT * 
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                'Excel 12.0; Database=C:\Users\tcmnoc\Desktop\Test.xlsx;',
                [mySheet])

Without fuller context, I consider the following assumptions:没有更完整的上下文,我考虑以下假设:

  • Maybe Excel is connected to the [TradeCloud].[dbo].[Adminlist] table?也许 Excel 已连接到[TradeCloud].[dbo].[Adminlist]表? If so, you need to make a separate, direct connection to the database and schema to access the table (bypassing Excel which is just another client connection).如果是这样,您需要与数据库和架构建立单独的直接连接以访问表(绕过 Excel,它只是另一个客户端连接)。

  • Maybe you meant to populate an existing SQL Server table?也许您打算填充现有的 SQL Server 表? If so, run the needed append or create-table command then browse its contents:如果是这样,请运行所需的 append 或 create-table 命令,然后浏览其内容:

     -- APPEND TO TABLE INSERT INTO [TradeCloud].[dbo].[Adminlist] (Col1, Col2, Col3, ...) SELECT xl.Col1, xl.Col2, xl.Col3, ... FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0; Database=C:\\Users\\tcmnoc\\Desktop\\Test.xlsx;', [mySheet]) xl; -- CREATE TABLE SELECT xl.Col1, xl.Col2, xl.Col3, ... INTO [TradeCloud].[dbo].[Adminlist] FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0; Database=C:\\Users\\tcmnoc\\Desktop\\Test.xlsx;', [mySheet]) xl; -- BROWSE CONTENTS SELECT * [TradeCloud].[dbo].[Adminlist];
  • Maybe you are attempting to populate an Excel workbook?也许您正在尝试填充 Excel 工作簿? If so, do note, these commands ( OPENROWSET and OPENDATASOURCE ) do not populate an existing Excel workbook but simply connects to external sources (Excel, Access, or other data sources) as a backend to retrieve data.如果是这样,请注意,这些命令( OPENROWSETOPENDATASOURCE )不会填充现有的 Excel 工作簿,而只是连接到外部源(Excel、Access 或其他数据源)作为检索数据的后端。

暂无
暂无

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

相关问题 链接服务器“(null)”的 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0” - The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" 无法为链接服务器初始化OLE DB提供程序“ Microsoft.ACE.OLEDB.12.0”的数据源对象 - Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server 无法在 64 位 SQL Server 上加载 32 位 OLE DB 提供程序“Microsoft.ACE.OLEDB.12.0” - The 32-bit OLE DB provider "Microsoft.ACE.OLEDB.12.0" cannot be loaded in-process on a 64-bit SQL Server 运行SQL脚本的批处理文件得到错误对OLE DB提供程序'Microsoft.ACE.OLEDB.12.0'的临时访问已被拒绝。 - Batch file that runs sql script getting error Ad hoc access to OLE DB provider 'Microsoft.ACE.OLEDB.12.0' has been denied.' 从 excel 导入到 sql server:'Microsoft.ACE.OLEDB.12.0' 提供程序错误 - import from excel to sql server: The 'Microsoft.ACE.OLEDB.12.0' provider error Microsoft.ACE.OLEDB.12.0错误 - Microsoft.ACE.OLEDB.12.0 Error 链接服务器“(null)”的 OLE DB 提供程序“Microsoft.Jet.OLEDB.4.0”报告错误 - The OLE DB provider “Microsoft.Jet.OLEDB.4.0” for linked server “(null)” reported an error 错误:“OLE DB提供程序”MSDASQL“用于链接服务器”(null)“返回消息”[Microsoft] [ODBC驱动程序管理器]未找到数据源名称...“ - Error: “OLE DB provider ”MSDASQL“ for linked server ”(null)“ returned message ”[Microsoft][ODBC Driver Manager] Data source name not found …" 无法为链接服务器创建 OLE DB 提供程序 Microsoft.Jet.OLEDB.4.0 的实例 null - Cannot create an instance of OLE DB provider Microsoft.Jet.OLEDB.4.0 for linked server null Microsoft.ACE.OLEDB.12.0无法执行查询 - Microsoft.ACE.OLEDB.12.0 Cannot execute the query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM