update b set Name='-'+Name from 表A a,表B b where a.Name=b.Name and a.state=1
insert 表B select * from 表A

解决方案 »

  1.   

    --表A的State为1的更新相应记录使Name字段前面加个“-”符update b set name='-'+namefrom 表A,表B b where b.name=a.name and a.state=1
    --同时复制之前的那条记录到自已表中
    不懂啥意思
      

  2.   

    -- 表A的State为1的更新相应记录使Name字段前面加个“-”符
    update b set name='-'+b.name
    from b,a
    where a.no=b.no and a.state=1--同时复制之前的那条记录到自已表中
    insert b select * from A
      

  3.   

    -- 表A的State为1的更新相应记录使Name字段前面加个“-”符
    update b set name='-'+b.name
    from b,a
    where a.no=b.no and a.state=1-- 同时复制之前的那条记录到自已表中(如果只复制被更新的)
    insert b select a.*
    from b,a
    where a.no=b.no and a.state=1
      

  4.   

    邹建正解,其实这里是要遍历整个表A检查a.state=1,都要更新相应B表的记录的,这样的话用游标吗?事务处理?更新完表B后又要将表A的state状态变为2.这样的话又怎么处理呢?谢谢
      

  5.   

    -- 遍历整个表A检查a.state=1,都要更新相应B表的记录的
    update b set name='-'+b.name
    from b,a
    where a.no=b.no and a.state=1
    -- 这个update 会自动遍历, 而且它本身就是在一个事务中, 所以你不需要做事务处理.
      

  6.   

    -- 更新完表B后又要将表A的state状态变为2-- 那就再加多一个 update 语句
    update a set state=2
    from b,a
    where a.no=b.no and a.state=1