表一T1字段  Pno,Mno,A,B,C,D
表二T2字段  Mno,A,B,C,D
现在要取出t2中的Mno,A,B,C,D,来更新t1中某条的纪录,或插入一条新的纪录。只解决第二个插入不给分!

解决方案 »

  1.   

    declare
    @Mno as nvarchar(100),
    @A  as nvarchar(100),
    @b as nvarchar(100),
    @c as nvarchar(100),
    @d as nvarchar(100)
    select @Mno=Mno,@A=A,@B=B,@C=C,@D=D from t2 where 条件
    update t1 set Mno=@Mno,A=@A,B=@B,C=@C,D=@D where 条件
      

  2.   

    update T1 set a.A =b.A, a.B =b.B, a.C =b.C, a.D =b.D
     from t1 a,t2 b
      where a.mno = b.mno
    以上是更新,插入就不用说了吧!
      

  3.   

    楼上在更新列名前使用的前缀只怕通过过更新t1中某条的纪录update t1
    set A=T2.A,
        B=T2.B,
        C=T2.C,
        D=T2.D 
    from T2 where T1.Pno=T2.Mno
      

  4.   

    对不起,我也错了!更新t1中某条的纪录update t1
    set t1.A=T2.A,
        t1.B=T2.B,
        t1.C=T2.C,
        t1.D=T2.D 
    from T2 where T1.Pno=T2.Mno
      

  5.   

    update T1 set a.A =b.A, a.B =b.B, a.C =b.C, a.D =b.D
     from t1 a,t2 b
      where a.mno = b.mno
      

  6.   

    to noil0125(珏心) :   是吗?你试了吗?是可以的!你可以查下TSQL的帮助!
      

  7.   

    update T1 set 
     A =b.A, 
     B =b.B, 
     C =b.C, 
     D =b.D
     from t1 a,t2 b
     where a.mno = b.mno
      

  8.   

    update a set a.A =b.A, a.B =b.B, a.C =b.C, a.D =b.D
     from t1 a,t2 b
      where a.mno = b.mno