Cannot read Excel file from SQL Server with multiple versions of SQL Server -
exec sp_configure 'show advanced options', 1 reconfigure go exec sp_configure 'ad hoc distributed queries', 1 reconfigure go use [master] go exec master.dbo.sp_msset_oledb_prop n'microsoft.ace.oledb.12.0', n'allowinprocess', 1 go exec master.dbo.sp_msset_oledb_prop n'microsoft.ace.oledb.12.0', n'dynamicparameters', 1 go
reading excel
declare @sqlconnect varchar(8000) set @sqlconnect = 'select * openrowset(''microsoft.ace.oledb.12.0'', ''excel 8.0;database=d:\wages.xlsx;'', ''select * [sheet2$]'')' exec (@sqlconnect)
exception
msg 7399, level 16, state 1, line 1
ole db provider "microsoft.ace.oledb.12.0" linked server "(null)" reported error. provider reported unexpected catastrophic failure.msg 7303, level 16, state 1, line 1
cannot initialize data source object of ole db provider "microsoft.ace.oledb.12.0" linked server "(null)".
sometimes gives error goes in infinite loop of execution.
note: getting error after installing sql server 2008 r2 on sql server 2012.
- os: windows 7 32-bit
- sql server 2008 r2 , sql server 2012 installed
the sql server error message if user have no rights sql server temp directory:
ole db provider "microsoft.jet.oledb.4.0" linked server "(null)" returned message "unspecified error".
msg 7303, level 16, state 1, line 1
cannot initialize data source object of ole db provider "microsoft.jet.oledb.4.0" linked server "(null)".
grant rigths temp directory
(i.) step required 32-bit sql server ole db provider
the main problem ole db provider creates temporary file during query in sql server temp directory using credentials of user run query.
the default directory sql server default directory sql server service account.
if sql server run under network service account temp directory like:
c:\windows\serviceprofiles\networkservice\appdata\local\temp
if sql server run under local service account temp directory like:
c:\windows\serviceprofiles\localservice\appdata\local\temp
microsoft recommends 2 ways solution:
a change of sql server temp directory , grant of full rights users directory. grant of read/write rights current sql server temp directory.
see details: prb: "unspecified error" error 7399 using openrowset against jet database
usually few accounts used import operations. can add rights these accounts.
for example, icacls utility can used rights setup:
icacls c:\windows\serviceprofiles\networkservice\appdata\local\temp /grant vs:(r,w)
for more information follow link
Comments
Post a Comment