title: Probleme OLE DB provider
body: <p>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 </p>
  
  <p>I'm on Windows 7 64 bit, SQL Server 2008 Express. I import a file format  (.xls) </p>
  
  <p>Here's the code:</p>
  
  <pre><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]
  </code></pre>
  
  <p>and this is the error :</p>
  
  <blockquote>
    <p>Msg 7308, Level 16, State 1, Line 1<br>
    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.</p>
  </blockquote>
  
  <p>And I forget I also do this : </p>
  
  <p>and I changed my query of course to this </p>
  
  <pre><code>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]
  </code></pre>
  
  <p>and this is the error:</p>
  
  <blockquote>
    <p>Msg 15281, Level 16, State 1, Line 1<br>
    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.</p>
  </blockquote>
  
  <p>After I edited my code using this code I found it here  : 
  <a href="https://stackoverflow.com/questions/12090555/get-excel-sheet-into-temp-table-using-a-script?rq=1">Get Excel sheet into temp table using a script</a></p>
  
  <p>in stackoverflow </p>
  
  <pre><code>sp_configure 'show advanced options', 1;
  
  RECONFIGURE;
  GO
  
  sp_configure 'Ad Hoc Distributed Queries', 1;
  GO
  
  RECONFIGURE;
  GO
  </code></pre>
  
  <p>and after I execute my query </p>
  
  <pre><code>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]
  </code></pre>
  
  <p>The error change to this  :</p>
  
  <blockquote>
    <p>Msg 7302, Level 16, State 1, Line 1<br>
    Can not create an instance of OLE DB provider "MICROSOFT.ACE.OLEDB.12.0" for linked server "(null)"</p>
  </blockquote>
  
  <p>Help please</p>