有一个EXECL表,里面有字段EXID(唯一),DJ   (单价),sqlserver数据库中有表item,字段ID,DJ(单价) 
现在我要跟据EXECL中的数据去更新SQLSERVER中表item中的单价,ID相同时更新,请问怎么实现

解决方案 »

  1.   

    update item set dj = b.dj
    from item a
    join opendatasource(..) b on EXID=id
      

  2.   

    update t1 set f2 = b.f2
    from t1 a
    join opendatasource('Microsoft.Jet.OLEDB.4.0','Data Source="D:\123.xls";User ID=Admin;Password=;Extended properties=Excel 5.0;Persist Security Info=false')...[Sheet1] b on a.f1=b.f1---(t1是数据库中的表,f1是对比字段,F2是要更新的字段,两个表中字段名相同,执行上面语句提示)
    服务器: 消息 7314,级别 16,状态 1,行 1
    OLE DB 提供程序 'Microsoft.Jet.OLEDB.4.0' 不包含表 'Sheet1'。该表可能不存在,或当前用户没有使用该表的权限。
      

  3.   

    update t1 set f2 = b.f2 
    from t1 a 
    join opendatasource('Microsoft.Jet.OLEDB.4.0','Data Source="D:\123.xls";User ID=Admin;Password=;Extended properties=Excel 5.0;Persist Security Info=false')...[$Sheet1] b on a.f1=b.f1
      

  4.   

    服务器: 消息 7399,级别 16,状态 1,行 1
    OLE DB 提供程序 'Microsoft.Jet.OLEDB.4.0' 报错。 
    [OLE/DB provider returned message: 找不到可安装的 ISAM。]还是报错,难道是我的机子环境有问题吗?????
      

  5.   

    我们使用txt文本进行更新,步骤是:1.通过程序读取txt文本内容.
    2.将内容插入临时表.
    3.写一个存储过程来判断主键相同时进行更新。通过存储过程来执行,速度是很快的,可以尝试!