例如:    T1            T2                         T3  A   B1        A   B2                   A   B1  B2
  a   6         b   9  ----------->      a   6
  c   8         d   5                    c   8
  f                                      f
                                         b       9
                                         d       5把T1和T2的A字段合併為一個字段,B1和B2同時並列出現,不知道這樣說清楚了沒有?

解决方案 »

  1.   

    SELECT * INTO t3 from t1 UNION ALL select * from t2
      

  2.   

    SELECT a,b1,null b2 INTO t3 from t1 UNION ALL select a,null b1,b2 from t2
      

  3.   

    select * INTO t3 from (SELECT a,b1,null b2 from t1 UNION ALL select a,null b1,b2 from t2) tem
      

  4.   

    数据不一样,但目的达到:
    create table t3 (a  char,b1 int)
    create table t4 (a char,b2 int)
    insert into t3 select 'a',6insert into t3 select 'c',8insert into t3 select 'f',null
    insert into t4 select 'a',7
    insert into t4 select 'c',null
    insert into t4 select 'h',8select isnull(t3.a,t4.a),b1,b2 from t3 full  join t4 on t3.a=t4.aresult:
    a 6 7
    c 8 NULL
    h NULL 8
    f NULL NULL