[英]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: 问题:
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.
我认为有几个问题。
*.txt;
*.txt;
之间添加一个空格*.txt;
and *.csv
*.csv
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.