从一个excel文件中查询数据:select * from OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\abc.xls',[abc$])出错:伺服器: 訊息 7314,層級 16,狀態 1,行 1
OLE DB provider 'MICROSOFT.JET.OLEDB.4.0' does not contain table 'abc$'.  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='abc$'].

解决方案 »

  1.   

    有abc这个sheet吗
    -----------------
    有的,打开abc.xls后在excel的左下角有个abc名称,不是sheet1.
      

  2.   

    可以这么试试:
    SELECT * 
    FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source="c:\abc.xls";User ID=Admin;Password=;Extended properties=Excel 8.0')...[abc$]
      

  3.   

    可以这么试试:
    SELECT * 
    FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source="c:\abc.xls";User ID=Admin;Password=;Extended properties=Excel 8.0')...[abc$]
    --------------------------------------------------------------------------------
    也出错:伺服器: 訊息 7314,層級 16,狀態 1,行 1
    OLE DB provider 'Microsoft.Jet.OLEDB.4.0' does not contain table 'abc$'.  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='abc$'].郁闷啊!
      

  4.   

    注意机子上装没装oledb4.0版本,另外执行语句的时候excel文件不要打开
      

  5.   

    select * from OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\abc.xls',abc$)拿掉中括号试一下
      

  6.   

    注意数据类型,试一下把excel表第一行设为冻结窗口,excel第一行填列名
      

  7.   

    注意机子上装没装oledb4.0版本,另外执行语句的时候excel文件不要打开
    ---------------------------------------------------------------------怎样才知道有没有装oledb4.0版本?我不知道哦。