You are here:Home » tsql » script to fetch data from Excel

script to fetch data from Excel

EXEC sp_addlinkedserver 'ImportData',
'Jet 4.0', 'Microsoft.Jet.OLEDB.4.0',
'\\DSK07\Migrate\Data_reel.xls',
NULL,
'Excel 8.0'
GO

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=\\DSK07\Migrate\Data_reel.xls', 'SELECT * FROM COMM')

SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=\\DSK07\Migrate\Data_reel.xls;Extended Properties=Excel 8.0')...COMM

SELECT * FROM OPENQUERY(ImportData, 'SELECT * FROM COMM')