title: FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0' ,'Excel 12.0... works when user runs it, but not when SQL Server Agent runs the job; no error
body: <p>I have seen so many variations on this topic, so I had assumed I should be able to find an answer, but I am stumped. Here's the situation.</p>
  <p>Running SSMS v18.11.1.</p>
  <p>I have a task that that runs every minute. On step 3, it determines which stored procedure to run based on the file name. Counts the records in the table to which it will upload, grabs the data from the file using OPENROWSET and 'Microsoft.ACE.OLEDB.12.0', scrubs the data (duplicates/updates/etc), then counts the table again to see how many it added. Finally it sends an email with the final details.</p>
  <p>There are no errors recorded in the server agent job history and I reduced what it wrote to make sure I wasn't missing it by overflow. It only fails when the job is run automatically. And by fail, I mean that it shows no records were added. When I run it step by step manually, it works. The same flow works on all other files (txt or pdf), but not for this excel file (xlsx).</p>
  <p>From the records, it seems to be failing here:</p>
  <pre><code>SELECT
  *
  ,src_file_nm = 'F:\Clients\ClientName\TPA\20220609\FileName.xlsx'
  ,id = ROW_NUMBER() OVER (ORDER BY (SELECT 0))
  INTO TPA.PrescriptionCol86
  FROM OPENROWSET(
  'Microsoft.ACE.OLEDB.12.0'
  ,'Excel 12.0;HDR=YES;Database=F:\Clients\ClientName\TPA\20220609\FileName.xlsx'
  ,'SELECT * FROM [Page1_1$A9:CH]'
  )
  WHERE [Carrier NAME] IS NOT NULL
  
  </code></pre>
  <p>But, again, no error messages for me to go from. It just shows that there were zero records found, but in actuality there are over 10,000 most days.</p>
  <p>The job is Executed as user: NT SERVICE\SQLSERVERAGENT. Based on the Server Roles, it should be able to perform this type of data:
  <a href="https://i.stack.imgur.com/Wy3lH.png" rel="nofollow noreferrer">sysadmin privileges</a></p>
  <p>Adhoc access is allowed; <a href="https://i.stack.imgur.com/T8pMw.png" rel="nofollow noreferrer">see other settings as well here.</a></p>
  <pre><code>EXEC master.sys.sp_MSset_oledb_prop
  </code></pre>
  <p>Results in <a href="https://i.stack.imgur.com/Tf3gy.png" rel="nofollow noreferrer">showing more properties</a>, in case it is important.</p>
  <p>The server has Excel 365 installed.</p>
  <p>Any suggestions I might try to get it to run correctly during the server job?</p>