/*
OFFICE 2003
如果接受数据导入的表已经存在:
*/
INSERT INTO DemoTable
SELECT *
FROM OPENROWSET
(
'MICROSOFT.JET.OLEDB.4.0'
,
'Excel 5.0;HDR=YES;DATABASE=D:\Demo.xls'
,sheet1$
)
/*
如果导入数据并生成表:
*/
SELECT * INTO DemoTable
FROM OPENROWSET
(
'MICROSOFT.JET.OLEDB.4.0'
,
'Excel 5.0;HDR=YES;DATABASE=D:\Demo.xls'
,sheet1$
)

/*===================================*/

/*
OFFICE 2010
如果表已存在,SQL语句为:
*/
INSERT INTO DemoTable
SELECT *
FROM OPENDATASOURCE
(
'Microsoft.Ace.OLEDB.12.0'
,
'Data Source=D:\Demo.xlsx;Extended Properties=Excel 12.0'
)
...
[sheet1$]

/*
如果表不存在,SQL语句为:
*/
SELECT * INTO DemoTable
FROM OPENDATASOURCE
(
'Microsoft.Ace.OLEDB.12.0'
,
'Data Source=D:\Demo.xlsx;Extended Properties=Excel 12.0'
)...
[sheet1$]

转载至:http://www.cnblogs.com/txst/archive/2011/04/21/2023372.html

 

 

相关文章:

  • 2021-09-20
  • 2022-02-13
  • 2021-08-08
  • 2021-04-03
  • 2021-12-23
  • 2021-12-27
  • 2021-12-08
  • 2021-04-21
猜你喜欢
  • 2022-02-25
  • 2021-06-29
  • 2022-01-02
  • 2021-12-23
  • 2021-12-06
  • 2021-12-05
相关资源
相似解决方案