Error: “OLE DB provider ”MSDASQL“ for linked server ”(null)“ returned message ”[Microsoft][ODBC Driver Manager] Data source name not found …"

前端 未结 2 1282
误落风尘
误落风尘 2020-12-17 02:53

If I execute the following command:

select 
    * 
from 
    OpenRowset (
        \'MSDASQL\',
        \'Driver={Microsoft Text Driver (*.txt;*.csv)};Default         


        
相关标签:
2条回答
  • 2020-12-17 03:26

    I just tried it on x64 Win7 and made it work. I think there are a couple problems.

    1. I believe you have to add a space between *.txt; and *.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')
    
    0 讨论(0)
  • 2020-12-17 03:31

    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.

    On my machine (Win7, x64, SQL Server 2008 R2), Administrative Tools > Data Sources (ODBC) > Drivers, shows no driver called "Microsoft Text Driver". But there is a driver labeled "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. 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.

    0 讨论(0)
提交回复
热议问题