--office 2003
--If the table that accepts the data import already exists
INSERT INTO demotable SELECT * FROM
OPENROWSET (' MICROSOFT. JET. oledb.4.0 ', ' Excel 5.0; Hdr=yes;database=d:/demo.xls ', sheet1$)
--If you import data and generate a table
SELECT * Into demotable from OPENROWSET (' MICROSOFT. JET. oledb.4.0 ', ' Excel 5.0; Hdr=yes;database=d:/demo.xls ', sheet1$)
/***********************/
--office 2010
--if the table already exists, the SQL statement is:
INSERT INTO demotable select * from OpenDataSource (' microsoft.ace.oledb.12.0 ', ' Data source=d:/demo.xlsx; Extended properties=excel 12.0 ') ... [sheet1$]
--If the table does not exist, the SQL statement is:
SELECT * into demotable from OpenDataSource (' microsoft.ace.oledb.12.0 ', ' Data source=d:/demo.xlsx; Extended properties=excel 12.0 ') ... [sheet1$]
Excel file import SQL Server database table