Reputation: 139
I'm trying to get the headers of my Excel file. When I'm using this code:
SELECT TOP 1 *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;HDR=NO;Database=C:\myfolder\myfile.xlsx;', 'SELECT * FROM [Page1$]')
I get most of the columns, but some of them are NULL. I checked my file, the headers are all there, correctly placed, all of the headers are strings, there's data for each column, etc.
Do you have an idea of what's happening?
Upvotes: 0
Views: 695
Reputation: 13237
Could you please add IMEX=1;
before the HDR=NO;
and check the result.
So the query will be:
SELECT TOP 1 *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;IMEX=1;HDR=NO;Database=C:\myfolder\myfile.xlsx;', 'SELECT * FROM [Page1$]')
Upvotes: 1