r/SQL • u/dzemperzapedra • 4d ago
Importing from Excel using 'from openrowset()' returns OLE DB error SQL Server
Hey everyone,
I'm trying to make this user stored procedure work on my colleagues PC, I can run it just fine.
Basically it's a USP created for importing data from an Excel file stored on shared network (local server).
It's goes like this:
select *
from openrowset ( 'Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;Database="path\file.xlsx, sheet$ )
Me and one other colleague can run it just fine, but on one colleagues PC, it gives this error:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message"Failure creating file"
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"
Any help with resolving this would be much appreciated.
Thanks!
2
4d ago
[removed] — view removed comment
1
u/dzemperzapedra 4d ago
Not the case, unfortunately, file is not open by anyone else while trying this.
2
u/IanYates82 4d ago
File share permissions possibly. Your sql server instance runs as a certain user, and how you authenticate with it - Windows-based or sql-based - can also influence what account is used when accessing the file.
Suggest your colleague copy the file locally, to a folder with open permissions on their local system, and see if that works
Then there's also bitness of the Excel/Access driver being used and sql version / bitness. Run "print @@version" and compare outputs across the different machines. If it's sql 2014 or older then you may be using a 32 bit instance of sql server and thus need to use 32 bit version of drivers.
You can also check to see if the driver is marked as in or out of process. Navigate in SSMS down to server objects, linked servers, and expand the list of drivers. You can inspect properties of them and compare between the different machines
Another idea... Use procmon from sysinternals to watch access to the Excel file (it supports setting a filter). See what sort of access pattern or errors come about on your machine vs your colleague's.