USE [master]
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1
EXEC sp_configure 'show advanced options', 1
RECONFIGURE 
EXEC sp_configure 'Ad Hoc Distributed Queries', 1 
RECONFIGURE  
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 8.0;IMEX=1;HDR=YES;Database=文件路径', 'SELECT * FROM [Sheet1$]')
EXEC sp_configure 'Ad Hoc Distributed Queries', 0 
RECONFIGURE  
EXEC sp_configure 'show advanced options', 0
RECONFIGURE 
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 0
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 0
posted on 2011-12-02 12:03  尚書  阅读(638)  评论(0编辑  收藏  举报