下面这句
  insert into tb(a,b)
  SELECT t1,t2
  FROM OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="e:\test.xls";Extended Properties="Excel 8.0";Persist Security Info=False')...[Sheet1$]
放在查询分析器里能执行,放到存储过错中就报:"错误7392:未能为OLE DB提供程序'Microsoft.Jet.OLEDB4.0'启动事务"
请问如何解决?

解决方案 »

  1.   


    EXEC sp_configure 'show advanced options', 1
    GO
    -- To update the currently configured value for advanced options.
    RECONFIGURE
    GO
    -- To enable the feature.
    EXEC sp_configure 'xp_cmdshell', 1
    GO
    -- To update the currently configured value for this feature.
    RECONFIGURE
    GO insert into tb(a,b)
      SELECT t1,t2
      FROM OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="e:\test.xls";Extended Properties="Excel 8.0";Persist Security Info=False')...[Sheet1$]
    GO
    ------------------------------------------------------------------------------
    --一个例子
    将Excel的数据导入SQL server :
    -- ======================================================
    SELECT * into newtable
    FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
      'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
    实例:
    SELECT * into newtable
    FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
      'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions
      

  2.   

    try this,SET XACT_ABORT ON
    insert into tb(a,b)
     SELECT t1,t2
     FROM OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="e:\test.xls";Extended Properties="Excel 8.0";Persist Security Info=False')...[Sheet1$]
      

  3.   

    参考http://blog.csdn.net/orchidcat/article/details/7480680
      

  4.   

    LZ是否安装了execl,execl版本要和SQL Server对应吧