22,209
社区成员
发帖
与我相关
我的任务
分享
--3.2.1用openrowset函数,引用4.0的库
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls',
sheet1$)
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls', --文件必须存在
'select * from [sheet1$]') --表必须存在
/*=========================================================================
如果在要导入数据的目标机器上装有office2007及其以上版本,
那么可以用以下的方法导入扩展名为.xlsx,引用了库:microsoft.ACE.oledb.12.0,
excel的版本为:12.0
注意:不能在openrowset中写任何的空格等多余的字符,
否则会报错,而且错误没有针对性
===========================================================================*/
--3.2.2用openrowset函数,引用12.0的库
select *
from openrowset('microsoft.ace.oledb.12.0',
'Excel 12.0;database=c:\test.xlsx',
'select * from [sheet1$]')
[/quote]
你的意思是先用Openrowset函数,先查询出数据,然后自己进行类型转换之后,再插入数据库中,对么?
[/quote]
对的,就是这个意思,先尝试一下--3.2.1用openrowset函数,引用4.0的库
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls',
sheet1$)
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls', --文件必须存在
'select * from [sheet1$]') --表必须存在
/*=========================================================================
如果在要导入数据的目标机器上装有office2007及其以上版本,
那么可以用以下的方法导入扩展名为.xlsx,引用了库:microsoft.ACE.oledb.12.0,
excel的版本为:12.0
注意:不能在openrowset中写任何的空格等多余的字符,
否则会报错,而且错误没有针对性
===========================================================================*/
--3.2.2用openrowset函数,引用12.0的库
select *
from openrowset('microsoft.ace.oledb.12.0',
'Excel 12.0;database=c:\test.xlsx',
'select * from [sheet1$]')
[/quote]
你的意思是先用Openrowset函数,先查询出数据,然后自己进行类型转换之后,再插入数据库中,对么?
--3.2.1用openrowset函数,引用4.0的库
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls',
sheet1$)
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls', --文件必须存在
'select * from [sheet1$]') --表必须存在
/*=========================================================================
如果在要导入数据的目标机器上装有office2007及其以上版本,
那么可以用以下的方法导入扩展名为.xlsx,引用了库:microsoft.ACE.oledb.12.0,
excel的版本为:12.0
注意:不能在openrowset中写任何的空格等多余的字符,
否则会报错,而且错误没有针对性
===========================================================================*/
--3.2.2用openrowset函数,引用12.0的库
select *
from openrowset('microsoft.ace.oledb.12.0',
'Excel 12.0;database=c:\test.xlsx',
'select * from [sheet1$]')
--3.2.1用openrowset函数,引用4.0的库
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls',
sheet1$)
select *
from
openrowset('microsoft.jet.oledb.4.0',
'Excel 5.0;database=c:\t2.xls', --文件必须存在
'select * from [sheet1$]') --表必须存在
/*=========================================================================
如果在要导入数据的目标机器上装有office2007及其以上版本,
那么可以用以下的方法导入扩展名为.xlsx,引用了库:microsoft.ACE.oledb.12.0,
excel的版本为:12.0
注意:不能在openrowset中写任何的空格等多余的字符,
否则会报错,而且错误没有针对性
===========================================================================*/
--3.2.2用openrowset函数,引用12.0的库
select *
from openrowset('microsoft.ace.oledb.12.0',
'Excel 12.0;database=c:\test.xlsx',
'select * from [sheet1$]')