[英]Import multiple Excel files/sheets into SQL Table
I have about 100 xlsx files, all with 1-7 sheets each. 我大约有100个xlsx文件,每个文件都有1-7张纸。 Each file and sheet has the same columns as the table I want to import everything into.
每个文件和工作表都与我要将所有内容导入到的表的列相同。
I can use this successfully: 我可以成功使用它:
SELECT *
FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\0.xlsx',
'SELECT * FROM [sheet1$]'
)
or 要么
SELECT * FROM OPENDATASOURCE( 'Microsoft.ACE.OLEDB.12.0', 'Data Source="C:\0.xlsx";
Extended properties=Excel 8.0')...Sheet1$
But how can I import multiple sheets from a file? 但是,如何从一个文件导入多张图纸?
Linked Server 链接服务器
EXEC sp_addlinkedserver
@server = 'ExcelServer1',
@srvproduct = 'Excel',
@provider = 'Microsoft.Jet.OLEDB.4.0',
@datasrc = 'C:\Test\excel-sql-server.xls',
@provstr = 'Excel 8.0;IMEX=1;HDR=YES;'
EXEC sp_dropserver
@server = N'ExcelServer1',
@droplogins='droplogins'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.