- Create a Linked Server
- Server Objects --> Linked Servers --> Right-Click --> New Linked Server...
- name the linked server MSDASQL
- Provider is: Microsoft Jet 4.0 OLD DB Provider
- Product Name: Jet 4.0
- Data Source is the location of your excel file (include the file name? it has been a while...)
- Provider String: Excel 8.0
SELECT *
INTO tmpRaw_tbl
FROM
OPENROWSET('MSDASQL', 'Driver=Microsoft Excel Driver
(*.xls);DBQ=C:\Company Folders\CorporateUpload\sub\subs.xls;', 'SELECT * FROM [Sheet1$] WHERE [MyCol] NOT LIKE ''blah%''')
AS derivedtbl_1
It will render this:
SELECT * FROM tmpRaw_tbl
There are a few reasons why you would get a NULL return string error.
- the file may be open
- file name is wrong (or the location)
- you have to hae [Sheet1$] in brackets with the dollar sign in order for the Jet Engine to read the file.
Other interesting things
Look up schema.ini formatting. You can define what each column format is, according to Jet standards...
No comments:
Post a Comment