如何将EXCEL表中的数据导入数据库中

时间:2022-10-20 13:36:08
--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$]