Export Data from SQL Server 2014 to Excel
<p>I tried to export data from SQL Server 2014 to Excel.</p>

<p>I tried like this </p>

<pre><code>insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0
Xml;HDR=YES;Database=D:\testing.xlsx;', 
'SELECT OI_NAME,OI_ADDRESSS FROM [Sheet1$]') select OI_NAME,
OI_ADDRESSS from OI_TEMP
</code></pre>

<p>But I get this error </p>

<blockquote>
  <p>OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error".</p>
  
  <p>Msg 7303, Level 16, State 1, Line 1<br>
  Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".</p>
</blockquote>

<p>I searched on the internet, and found this:</p>

<blockquote>
  <p>The SQL Server Error Message if a user have no rights for SQL Server TEMP directory OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".<br>
  Msg 7303, Level 16, State 1, Line 1<br>
  Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".</p>
</blockquote>

<p>But I assign permission is still does not work.</p>

<p>Why?</p>