Excel文件导入SQL Server数据库表
时间:2011-04-23 来源:moss_tan_jun
--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$]
--如果接受数据导入的表已经存在
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$]
相关阅读 更多 +