title: Export Sql server data to Excel by using Query
body: <p>I am trying to export the SQL server data to the excel file with using the sql query. But i am getting error </p>
  
  <p><code>OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified 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)".</code></p>
  
  <p>The Query which i am using</p>
  
  <pre><code>select * from OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\share\Test1.xlsx;HDR=YES','SELECT id FROM [Sheet1$]') SELECT id FROM Table
  </code></pre>
  
  <p>I have also enabled</p>
  
  <pre><code>sp_configure 'show advanced options', 1;
  GO
  RECONFIGURE;
  GO
  sp_configure 'Ad Hoc Distributed Queries', 1;
  GO
  RECONFIGURE
  
  
   EXEC master.dbo.sp_MSset_oledb_prop 'Microsoft.Jet.OLEDB.4.0', 'AllowInProcess', 0 
  GO 
  EXEC master.dbo.sp_MSset_oledb_prop 'Microsoft.Jet.OLEDB.4.0', 'DynamicParameters', 0
  GO 
  </code></pre>
  
  <p>I have also shared my folder with full permissions.
  I have Given the Excel file same headers with the table name
  But Same Error</p>