/* 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$ ]
转载至: