SQl 语句是Excel中的数据导入到SQL Service数据库中

来源:互联网 发布:linux泛文件 编辑:程序博客网 时间:2024/06/05 10:43
  1. //第一步:
  2. //启用Ad Hoc Distributed Queries:
  3. exec sp_configure 'show advanced options',1
  4. reconfigure
  5. exec sp_configure 'Ad Hoc Distributed Queries',1
  6. reconfigure
  7. go
  8. //第二步:
  9. SELECT * into  dbo.tabel5
  10. FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
  11.   'Data Source="D:/book.xls";Extended properties=Excel 5.0')...[Sheet1$] 
  12. go
  13. //第三步:
  14. //使用完成后,关闭Ad Hoc Distributed Queries:
  15. exec sp_configure 'Ad Hoc Distributed Queries',0
  16. reconfigure
  17. exec sp_configure 'show advanced options',0
  18. reconfigure  
  19. go
原创粉丝点击