insert into 表(col1,col2,col3...)
select col1,col2,col3... from OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=e:\test.xls',sheet1$)
select * into 表 from OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=e:\test1.xls',sheet3$)

解决方案 »

  1.   

    hdhai9451(New New People---新新人类):我试过这样写,但是因为excel和数据库不在同一台机器上,所以执行的时候总是提示找不到表。这是执行的时候给出的提示:OLE DB provider 'Microsoft.Jet.OLEDB.4.0' does not contain table 'tbl_test$'.  The table either does not exist or the current user does not have permissions on that table.
    OLE DB error trace [Non-interface error:  OLE DB provider does not contain the table: ProviderName='Microsoft.Jet.OLEDB.4.0', TableName='tbl_test$'].
      

  2.   

    为什么不先把Excel拷贝到服务器,这样不就可以找到了。
    SELECT * into test
    FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
      'Data Source="D:\test.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions