Search

Tuesday, June 5, 2012

script to fetch data from Excel

EXEC sp_addlinkedserver 'ImportData', 
'Jet 4.0', 'Microsoft.Jet.OLEDB.4.0', 
'C:\Users\XXXX\Documents\UserData.xls', 
NULL, 
'Excel 8.0' 
GO 

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=
C:\Users\XXXX\Documents\UserData.xls, 'SELECT * FROM COMM') 

SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=
C:\Users\XXXX\Documents\UserData.xls;Extended Properties=Excel 8.0')...COMM

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

No comments:

Post a Comment