游子吟

致力于.Net,致力于企业信息化工程!
Harvest = Hope + Struggle

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 一、导入到 Mysql 数据库

     先将excel 文件另存为 *.csv 文件,然后执行下列命令。

 load data local infile "path.csv" into talble(col1,col2,col3,col4,...);

 

二、导入Sql Server 数据库

     首先需要开户 Ad Hoc Distributed Queries 选项,开户方法如下:

 exec sp_configure 'show advanced options',1 

reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

 

然后执行:

SELECT * into newtable
FROM OpenDataSource'Microsoft.Jet.OLEDB.4.0', 'Data Source="F:\一页管理.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]  

 

 最后关闭 Ad Hoc Distributed Queries 选项

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

reconfigure 


 

 


posted on 2011-11-23 21:19  巴山游子  阅读(2407)  评论(0编辑  收藏  举报