Question

I am reading excel sheet using openrowset function?

My Excel sheet has numeric value in General Type Column. For some reason these values are brought over as nulls even though they have a values. I am not sure why this is happening. I looked into the format of the fields and they are set to General in Excel, I tried setting them to Text and that did not help.

I tried to bring the contents from the excel source to a text file in csv format and for some reason the Text field containing numeric value came out as blank (NULL).

Any inputs on getting this addressed will be much appreciated.

SET @Cmd = 'INSERT INTO Table_01
                SELECT * FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'', ''Excel 8.0;Database=' + @ExcelFilePath + ''',
                ''SELECT * FROM [Sheet1$]'')'
    EXEC(@Cmd)
Was it helpful?

Solution

This is to do with TypeGuessRows and IMEX:

OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;HDR=YES;IMEX=1;Database=x.xls',
'SELECT * FROM [Sheet2$]');

TypeGuesssRows can be found at:

HKEY_Local_Machine/Software/Microsoft/Jet/4.0/Engines/Excel/

A value of 0 means all rows.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top