exec sp_configure 'show advanced options',1

reconfigure

exec sp_configure 'Ad Hoc Distributed Queries',1

RECONFIGURE

GO

EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1

EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1

GO

SELECT *

FROM

OPENROWSET('Microsoft.ACE.OLEDB.12.0',

'Excel 12.0;Database=C:\a.xlsx;hdr=yes;imex=1',

[sheet1$])

Go

SELECT *

FROM

OPENROWSET('Microsoft.ACE.OLEDB.12.0',

'Excel 12.0;Database=C:\a.xlsx;hdr=yes;imex=1',

[sheet2$])

GO

exec sp_configure 'Ad Hoc Distributed Queries',0

reconfigure

exec sp_configure 'show advanced options',0

reconfigure