create view VIEW_A
{
  user          varchar(20),
  password      varchar(20),
  kind          varchar(2)
}
;
insert into VIEW_A(user,password,kind) select user,password,'A' from A;
insert into VIEW_A(user,password,kind) select user,password,'B' from A;
insert into VIEW_A(user,password,kind) select user,password,'C' from A;
Go

解决方案 »

  1.   

    sorry,错了

    create view VIEW_A
    {
      user          varchar(20),
      password      varchar(20),
      kind          varchar(2)
    }
    ;
    insert into VIEW_A(user,password,kind) select user,password,'A' from A;
    insert into VIEW_A(user,password,kind) select user,password,'B' from B;
    insert into VIEW_A(user,password,kind) select user,password,'C' from C;
    Go
      

  2.   

    create view myvew as
    select 'TableA' as from, USER,PASSWORD from tableA
    union all
    select 'TableB' as from, USER,PASSWORD from tableB
    union all
    select 'TableC' as from, USER,PASSWORD from tableC
    go
      

  3.   

    select user , password , 'A' kind Form TA
    union all
    select user , password , 'B' kind Form TB
    union all
    select user , password , 'C' kind Form TC这样就可以了,但是在保存为视图的时候有个技巧,要不sql会认为你写的代码是非法的。
    方法就是,先写一个简单的视图,保存,退出,然后双击那个视图,把上面的sql语句copy到视图中,点击保存,搞定。
      

  4.   

    Create View  VIEW_A
    as
    select user , password , 'A' kind Form A
    union all
    select user , password , 'B' kind Form B
    union all
    select user , password , 'C' kind Form C
      

  5.   

    Create View  VIEW_A
    as
    (
    select user , password , 'A' as kind Form A
    union 
    select user , password , 'B' as kind Form B
    union 
    select user , password , 'C' as kind Form C
    )
      

  6.   

    create view myvew as
    select 'TableA' as from, USER,PASSWORD from tableA
    union all
    select 'TableB' as from, USER,PASSWORD from tableB
    union all
    select 'TableC' as from, USER,PASSWORD from tableC
    go