how change SSMS connection to remote server and run OPENROWSET on ACE.OLEDB.12.0

James R. Hill 1 Reputation point
2023-04-07T19:28:55.6666667+00:00

How to change connection via SSMS to different server and run : SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;HDR=YES;Database=.\fileshare name\excelsheet.xlsx :
this returns error = Cannot initialize the data source object of OLE DB provider

SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 121.9K Reputation points MVP Volunteer Moderator
    2023-04-08T08:28:25.54+00:00

    If you access the operating system on the server where this happens through Remote Desktop and open Task Manager, do you see any process for Excel? (Be sure to look under the Details tab). If you kill that process, does that resolve the situation?

    I have never used the ACE provider myself, but all through the years I've been monitoring SQL forums, there have been no end of posts where people have problems using the ACE engine. I can't escape the feeling that it is not a tenable solution. But then again, I never see posts from sites where everything is working OK.

    Anyway, in Object Explorer: Server Objects->Linked Servers->Providers find the the provider, check "Allow inprocess" and restart the instance. It may help for this problem. But it could also create new ones. If Excel crashes, this could now bring the entire instance down.


  2. Seeya Xi-MSFT 16,586 Reputation points
    2023-04-10T06:19:28.43+00:00

    Hi @James R. Hill,

    It seems that Excel file you are trying to query is already opened exclusively by another user.

    Check if the Excel file is opened by another user or process. If yes, ask them to close the file and try running the query again.

    Try adding the IMEX=1 parameter to the connection string in your query. This parameter sets the driver to use Import Mode, which may help in cases where the Excel file is opened in exclusive mode.

    Please refer to this blog: http://www.sql-server-helper.com/tips/read-import-excel-file-p03.aspx Best regards,

    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.