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
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
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
select a as f1,b as f2,c as f3,null as f4 from A union all select x,y,null,z
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
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 ---------------- 兩個在復制红尘的答案前,至少也檢查下錯誤。
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
高手们,Null能不能用0来代替。好像Access一样的做法。谢谢大家的帮助。
isnull(字段/变量,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 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
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
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
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
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
union all
select x,y,null,z
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
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
----------------
兩個在復制红尘的答案前,至少也檢查下錯誤。
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
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
高手们,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