Run the following statement to query the Excel content:
Select * From OpenDataSource ('Microsoft. Jet. oledb.4.0 ', 'Data source = c: \ book1.xls; extended properties = Excel 8.0')... [t_table $]
C: \ book1.xls is the path of the Excel file to be imported, and t_table $ is the name of the Excel table. (Do not miss the $ symbol), Excel 8.0 this is the Excel version number, the Office97-2000 version number is 8.0
For example, you can write the imported data as follows: in the SQL Server Query analyzer, Type
Insert into [t_table] ([u_name])
Select * From OpenDataSource ('Microsoft. Jet. oledb.4.0 ', 'Data source = c: \ book1.xls; extended properties = Excel 8.0')... [t_table $]
Ms provides the following methods:
Select * into xlimport3 from OpenDataSource ('Microsoft. Jet. oledb.4.0 ',
'Data source = c: \ test \ xltest.xls; extended properties = Excel 8.0 ')... [MERs $]
Select * into xlimport4 from OpenRowSet ('Microsoft. Jet. oledb.4.0 ',
'Excel 8.0; database = c: \ test \ xltest.xls ', [MERs $])
Select * into xlimport5 from OpenRowSet ('Microsoft. Jet. oledb.4.0 ',
'Excel 8.0; database = c: \ test \ xltest.xls ', 'select * from [MERs $]')
For details, see:
Http://support.microsoft.com/default.aspx? SCID = KB; ZH-CN; 321686