Problem with update sql with excel

…衆ロ難τιáo~ 提交于 2020-01-24 21:31:26

问题


I have a problem with this query:

UPDATE Provinces 
SET    Provinces.DefaultName=T2.Defaultname 
FROM   Provinces 
INNER JOIN 
    OPENROWSET('Microsoft.Jet.OLEDB.4.0',
               'Excel 8.0;Database=C:\provinces.xlsx;HDR=YES',
               'SELECT Code, Defaultname FROM [Arkusz1$]') T2 
     On Provinces.Code = t2.Code 
WHERE  Provinces.Code = T2.Code

I get error:

Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the error. Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

What is the source of this error, and how can I modify the SQL statement?


回答1:


There are several possible causes of this detailed here: Linked Server using Microsoft.Jet.OLEDB.4.0 problem.

A likely is cause is file system permissions of the temp directory for the sql service login for whoever is accessing that linked server: C:\Documents and Settings\(sql login name)\Local Settings\Temp




回答2:


That is permission denied error. Follow:

How to import data from Excel to SQL Server

How to use Excel with SQL Server linked servers and distributed queries

Note If you are using SQL Server 2005, make sure that you have enabled the Ad Hoc Distributed Queries option by using SQL Server Surface Area Configuration.

sp_configure 'Ad Hoc Distributed Queries', 1


来源:https://stackoverflow.com/questions/2810925/problem-with-update-sql-with-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!