Export data to Excel from SQL Server using OPENROWSET issue
<p>I am using the below script and got the following error:</p>

<blockquote>
  <p>Cannot create an instance of OLE DB provider
  "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".</p>
</blockquote>

<pre><code>EXEC SP_CONFIGURE 'show advanced options', 1; 
GO 
RECONFIGURE; 
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries', 1; 
GO 
RECONFIGURE; 

INSERT INTO OPENROWSET ('Microsoft.ACE.OLEDB.12.0', 
'Excel 12.0;Database=c:\CSV\testing.xlsx;', 
'SELECT * FROM [Sheet1$]') 
select top 10 * from Emp2
</code></pre>

<p>How can I fix this? I need to export data to Excel file in <strong>UNC path</strong>. Please guide me how to achieve it.</p>

<p>Again I try the below script too but this time I am getting a different error:</p>

<blockquote>
  <p>Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0"
  for linked server "(null)".</p>
</blockquote>

<pre><code>EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

INSERT INTO OPENROWSET 
   ('Microsoft.Jet.OLEDB.4.0', 
   'Excel 8.0;Database=c:\CSV\testing.xlsx;','SELECT ID,Name FROM [Sheet1$]')
   select top 10 * from Emp2
</code></pre>

<p>Please guide me how to export data to an Excel file which will be generated in UNC path.</p>