現有表table1,里面有一個ver_no 字段
如果ver_no >0 就把這條記錄与ver_no -1 的
記錄進行比較,然后對比兩條記錄的每一個字段
如有不同,就把記錄插入到tabel2中.

解决方案 »

  1.   

    insert into table2
    select a.* from table1 a
    inner join table1 b on a.ver_no = b.ver_no + 1 and
                           (
                             a.field1 <> b.field1 or
                             a.field2 <> b.field2 or
                             a.field3 <> b.field3 or
                                 ............
                           )
    where a.ver_no > 0
    这样写效率太低,不如用procedure实现
      

  2.   

    可是我要記錄每一個字段的改變
    然后把這些插到TABEL2的MEMO里同