[SQL Server] Excel文件导入SQL Server数据库表
时间:2011-04-22 来源:RyanBell
/*
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
相关阅读 更多 +