SQL excel

exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
GO

select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 8.0;HDR=YES;DATABASE=D:\Project\WorkingFolder\_1.xls',sheet1$)

--or:
/*
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
  'Data Source="D:\Project\WorkingFolder\_1.xls";User ID=Admin;Password=;Extended properties=Excel 8.0')...[Sheet1$]
*/

GO
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
GO

posted @ 2011-07-06 14:58  征服自己,征服世界  阅读(263)  评论(0)    收藏  举报