CopyCode The Code is as follows: exec sp_configure 'show advanced options', 1
Reconfigure
Exec sp_configure 'ad hoc distributed queries ', 1
Reconfigure
Copy codeThe Code is as follows: Select * From OpenDataSource ('Microsoft. Jet. oledb.4.0 ',
'Data source = E: \ haierweb \ myweb \ doc \ abc.xls; extended properties = Excel 8.0 ')... sheet1 $
The first line is used as the header.
The rest of the rows are considered to be of a data type and cannot be converted. If there is text or number, multiple rows are displayed, and the rest are null.
Employee information F2
Null name
664754 Zhang San
664783 Li Si
Null should be the employee ID. The first two rows are headers.
In this form, you should enter one more '(single quotation marks) before the number to forcibly convert it to the text format. Enter multiple cells with the same content, enter the characters, and press Ctrl + enter to enter the same characters in the selected cells.
Solution:Copy codeThe Code is as follows: Select * From OpenDataSource ('Microsoft. Jet. oledb.4.0 ',
'Data source = E: \ haierweb \ myweb \ doc \ abc.xls; extended properties = "Excel 8.0; HDR = yes; IMEX = 1;" ')... sheet1 $
HDR = yes, that is, the first column is used as the header.
IMEX = 1, which means to read the table content in a hybrid manner.
Jet supports so many databases, even HTML tables.