共有两个表,属于两台不同服务器的
TA(192.168.1.10),TB(192.168.10.11)TA表有以下表单
ID1,ID2,TA1,TA2TB表有如下
ID1,ID2,TB1,TB2,TA1,TA2两个表中的ID1,ID2是双主键TA中数据要插入到TB中,如果TB中存在TA数据则更新修改,如果不存在则插入新数据delphi代码该怎么写

解决方案 »

  1.   

    跟DELPHI没关系,纯粹的数据库问题。写存储过程比较合适。
      

  2.   

    update tb set tb.ta1=ta.ta1, tb.ta2 = ta.ta2
    from tb, ta 
    where tb.id1=ta.id1 and tb.id2 = ta.id2insert into tb(ta1,ta2)
    select * from ta 
    where convert(varchar(10),ta.id1)+convert(varchar(10),ta.id2) not in
          select  convert(varchar(10),tb.id1)+convert(varchar(10),tb.id2) from tb
      

  3.   

    If 
     Not Exists( Select 1 From table1 A where Not Exists( Select 1 From  table2 where id=A.id and Aid=A.Aid))Insert TableA Select '','','',''
    else
    Update A
    set ..
    From tableA  A
    Inner join TableB B
    on A.id=B.id ANd A.Aid=B.Aid