Reputation: 13049
I have about 100 xlsx files, all with 1-7 sheets each. 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?
Upvotes: 2
Views: 4008
Reputation: 2522
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'
Upvotes: 1