KEY存在的时候Update
不存在的时候Insert

解决方案 »

  1.   

    如果你要往A表导的时候,先导到B表,再检查B在A中存在就update,否则就insert
      

  2.   

    1. dts导入数据到临时表2. 执行sql脚本任务, 用sql语句处理
       --更新已经存在的
       update a set col1=b.col2, col2= b.col2, .... coln=b.coln
       from 目的表 a, 导入的临时表 b
       where a.keycol = b.key col
       -- 导入不存在的
       insert 目的表 select * from 导入的临时表 b
       where not exists(
          select * from 目的表 a where  a.keycol = b.key col)3. 删除临时表
      

  3.   

    同意邹老大的观点
     ”update a set col1=b.col1, col2= b.col2, .... coln=b.coln“
      

  4.   

    sql 2005 可以用ssis的相关组件直接实现
    一个数据流
    一个源数据源
    一个目标数据源
    一个oledb命令组件
    一个查找转换组件, 根据keycol查找, 查找成功的转到oledb命令组件执行update
                      查找失败的, 通过重定向, 直接插入目标数据源