I installed Office 2010 64 bit on Windows 7 64 bit. There is a SQL Server 2008 installed on windows 7 too.
Then I try to use Microsoft.ACE.OLEDB.12.0
to access data from excel file with T-SQL.
I try T-SQL in SQL Server Mgmt Studio with following kind of query:
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Temp\book1.xlsx;', 'SELECT * FROM [Sheet1$]')
If I start SQL Server Mgmt Studio with 'Run as Administrator', it is okay. I can access/insert data from/to the Excel file.
If I start Mgmt Studio directly (with my AD account), I will get error like:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
but actually, my account is also a admin account (it is in Local Administrator group and AD admin group).
Because I need to run T-SQL like OpenRowSet
in code, not sure how to resolve this issue.
Looks like OpenRowSet for this case only okay for local administrator to run MSSM.
I try to run MSSM from another computer, and got same error as above.
Figure it out: login as sa resolve this problem.