create view c
as 
select a as f1,b as f2,c as f3,null as f4 from A
union all
select x,y,null,z
go

解决方案 »

  1.   


    Create View C
    As
    Select a As f1, b As f2 , c As f3, Null As f4 From A
    Union All
    Select x, y, Null, z From B
    GO
      

  2.   


    create view c
    as 
    select a as f1,b as f2,c as f3,null as f4 from A
    union all
    select x,y,null,z
      

  3.   

    create table A(a int,b int,c int)
    insert into A select 1,2,3create table B(x int,y int,z int)
    insert into B select 4,5,6
    gocreate view c
    as 
    select a as f1,b as f2,c as f3,null as f4 from A
    union all
    select x,y,null,z from B
    goselect * from c
    godrop view c
    drop table A,B
    go
      

  4.   

    select a as f1,b as f2,c as f3,null as f4 from A
    union all
    select x,y,null,z
      

  5.   

    create table A(a int,b int,c int)
    insert into A select 1,2,3create table B(x int,y int,z int)
    insert into B select 4,5,6
    gocreate view c
    as 
    select a as f1,b as f2,c as f3,null as f4 from A
    union all
    select x,y,null,z from B
    goselect * from c
    /*
    f1          f2          f3          f4          
    ----------- ----------- ----------- ----------- 
    1           2           3           NULL
    4           5           NULL        6
    */
    godrop view c
    drop table A,B
    go
      

  6.   

    kk19840210(飞天小虫) ( ) 信誉:100  2007-08-10 16:33:03  得分: 0  
     
     
       
    create view c
    as 
    select a as f1,b as f2,c as f3,null as f4 from A
    union all
    select x,y,null,z  
     vchao13() ( ) 信誉:100  2007-08-10 16:33:29  得分: 0  
     
     
       select a as f1,b as f2,c as f3,null as f4 from A
    union all
    select x,y,null,z
    ----------------
    兩個在復制红尘的答案前,至少也檢查下錯誤。
      

  7.   

    create view v
    as 
    select a as f1,b as f2,c as f3,null as f4 from A
    union all
    select x,y,null,z from B
    go
      

  8.   

    高手们,Null能不能用0来代替。好像Access一样的做法。谢谢大家的帮助。
      

  9.   

    isnull(字段/变量,0)这次可不抄了
      

  10.   

    吧鱼的代码抄过来下Create View C
    As
    Select a As f1, b As f2 , c As f3, Null As f4 From A
    Union All
    Select x, y, Null, z From B
    GOselect isnull(f1,0) as f1,isnull(f2,0) as f2,isnull(f3,0) as f3,isnull(f4,0) as f4 from c
      

  11.   

    wujxchina() ( ) 信誉:100  2007-08-10 17:10:05  得分: 0  
     
     
       高手们,Null能不能用0来代替。好像Access一样的做法。谢谢大家的帮助。-------------------------------------- --如果只是將上面語句中的NULL改為0
    Create View C
    As
    Select a As f1, b As f2 , c As f3, 0 As f4 From A
    Union All
    Select x, y, 0, z From B
    GO--如果將表中的所有NULL的數據也顯示為0
    Create View C
    As
    Select IsNull(a, 0) As f1, IsNull(b, 0) As f2 , IsNull(c, 0) As f3, 0 As f4 From A
    Union All
    Select IsNull(x, 0), IsNull(y, 0), 0, IsNull(z, 0) From B
    GO