I have a problem when I try to import data from Excel to a table in SQL Server I have a problem I am totally blocked
I'm on Windows 7 64 bit, SQL Server 2008 Express. I import a file format (.xls)
Here's the code:
SELECT Table_1.Champ1 , Table_1.Champ2
FROM Table_1
INNER JOIN OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Users\AA\Desktop\Classeur1.xls;',
'SELECT [Champ1], [Champ2] FROM [Feuil1$]') T
ON Table_1.Champ1 = T.[Champ1]
and this is the error :
Msg 7308, Level 16, State 1, Line 1
The OLE DB provider 'Microsoft.Jet.OLEDB.4.0' can not be used for distributed queries because the provider is configured to run in STA mode.
And I forget I also do this :
and I changed my query of course to this
SELECT Table_1.Champ1 , Table_1.Champ2
FROM Table_1
INNER JOIN OPENROWSET('MICROSOFT.ACE.OLEDB.12.0',
'Excel 8.0;Database=C:\Users\AA\Desktop\Classeur1.xls;',
'SELECT [Champ1], [Champ2] FROM [Feuil1$]') T
ON Table_1.Champ1 = T.[Champ1]
and this is the error:
Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset / OpenDataSource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration of the server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration exposure" in Books Online for SQL Server.
After I edited my code using this code I found it here : Get Excel sheet into temp table using a script
in stackoverflow
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
and after I execute my query
SELECT Table_1.Champ1 , Table_1.Champ2
FROM Table_1
INNER JOIN OPENROWSET('MICROSOFT.ACE.OLEDB.12.0',
'Excel 8.0;Database=C:\Users\AA\Desktop\Classeur1.xls;',
'SELECT [Champ1], [Champ2] FROM [Feuil1$]') T
ON Table_1.Champ1 = T.[Champ1]
The error change to this :
Msg 7302, Level 16, State 1, Line 1
Can not create an instance of OLE DB provider "MICROSOFT.ACE.OLEDB.12.0" for linked server "(null)"
Help please
右键单击您的OLEDB Providor,然后转到“属性”并检查“允许进程中”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.