简体   繁体   English

错误:“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 …"

If I execute the following command: 如果我执行以下命令:

select 
    * 
from 
    OpenRowset (
        'MSDASQL',
        'Driver={Microsoft Text Driver (*.txt;*.csv)};DefaultDir=C:\;',
        'select top 10 * from C:\x.csv'
    )

... then Microsoft SQL Server Management Studio responds with: ...然后Microsoft SQL Server Management Studio响应:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. [Microsoft] [ODBC驱动程序管理器]未找到数据源名称且未指定默认驱动程序。

I'm running Microsoft SQL Server 2008 R2 on Win 7 x64. 我在Win 7 x64上运行Microsoft SQL Server 2008 R2。 I've also tried it on Windows Vista x32, same error. 我也在Windows Vista x32上试过它,同样的错误。

Questions: 问题:

  1. Has anyone successfully run this command on Win 7 x64? 有没有人在Win 7 x64上成功运行此命令?
  2. Do any of you know what could be causing the T-SQL command to fail like this? 你们中的任何人都知道可能导致T-SQL命令失败的原因吗?

Update 1: 更新1:

If you get an error that mentions "ad hoc queries", run the following to eliminate it: 如果您收到提及“即席查询”的错误,请运行以下命令以消除它:

EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO

Update 2: 更新2:

It works on an out-of-the-box Win7 x64 machine, but I still can't fix this error on my machine. 它适用于开箱即用的Win7 x64机器,但我仍然无法在我的机器上修复此错误。 I'll go with "bulk insert" (see my comments below). 我会选择“批量插入”(请参阅​​下面的评论)。

Solution: I've just wrestled with this issue for several hours on a Win7 x64 machine, and it is so difficult to find a good answer online that I thought I'd contribute one to this thread belatedly. 解决方案:我刚刚在Win7 x64机器上花了几个小时来解决这个问题,而且很难在网上找到一个好的答案,我以为我会在这个问题上为这个问题做出贡献。

On my machine (Win7, x64, SQL Server 2008 R2), Administrative Tools > Data Sources (ODBC) > Drivers, shows no driver called "Microsoft Text Driver". 在我的计算机(Win7,x64,SQL Server 2008 R2)上,管理工具>数据源(ODBC)>驱动程序,不显示名为“Microsoft Text Driver”的驱动程序。 But there is a driver labeled "Microsoft Access Text Driver (*.txt, *.csv)" 但是有一个标有“Microsoft Access Text Driver(* .txt,* .csv)”的驱动程序

I was able to change the driver name in code similar to the original questioner's INCLUDING the parentheses (*.txt, *.csv) WITH a comma and a space, not a semicolon. 我能够在代码中更改驱动程序名称,类似于原始提问者包含括号(* .txt,* .csv)的逗号和空格,而不是分号。 And it worked. 它奏效了。

select 
    * 
from 
    OpenRowset (
        'MSDASQL',
        'Driver={Microsoft Access Text Driver (*.txt, *.csv)};DefaultDir=C:\;',
        'select top 10 * from C:\x.csv'
    )

Note that the syntax in specifying the drive must be exactly the same. 请注意,指定驱动器的语法必须完全相同。 I can vouch for that because I went through several wrong iterations. 我可以担保,因为我经历了几次错误的迭代。

I just tried it on x64 Win7 and made it work. 我刚刚在x64 Win7上试过它并使它工作。 I think there are a couple problems. 我认为有几个问题。

  1. I believe you have to add a space between *.txt; 我相信你必须在*.txt;之间添加一个空格*.txt; and *.csv *.csv
  2. Don't include the path with the file name 不要包含带有文件名的路径

This worked: 这有效:

select * from OpenRowset('MSDASQL', 
         'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=c:\;', 
         'select top 10 * from x.csv')

暂无
暂无

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

相关问题 链接服务器“(null)”的OLE DB提供程序“ MSDASQL”报告错误 - The OLE DB provider “MSDASQL” for linked server “(null)” reported an error 链接服务器“(null)”的 OLE DB 提供程序“MSDASQL”无法更新表“[MSDASQL]”。 Pervasive 的未知提供程序错误 - The OLE DB provider "MSDASQL" for linked server "(null)" could not UPDATE table "[MSDASQL]". Unknown provider error with Pervasive 链接服务器“(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.” 错误:链接服务器“bquick”的 OLE DB 提供程序“MSDASQL”无法开始分布式事务 - Error: OLE DB provider "MSDASQL'' for Linked Server ''bequick'' was unable to begin a Distributed transaction 无法连接到数据库错误:java.sql.SQLException:[Microsoft] [ODBC驱动程序管理器]找不到数据源名称并且未指定默认驱动程序 - Cannot connect to database Error: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 无法为链接服务器初始化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 数据库 - [Microsoft] [ODBC驱动程序管理器]未找到数据源名称且未指定默认驱动程序 - Database - [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified OLE DB提供程序“ MSDASQL”报告了错误 - OLE DB provider 'MSDASQL' reported an error [Microsoft] [ODBC驱动程序管理器]找不到数据源名称且未指定默认驱动程序-在IDE中工作正常-一次没有导出 - [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified - works fine in IDE - not once exported 链接服务器“(null)”的 OLE DB 提供程序“Microsoft.Jet.OLEDB.4.0”报告错误 - The OLE DB provider “Microsoft.Jet.OLEDB.4.0” for linked server “(null)” reported an error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM