表Table1
里面有列A,B,C,D,E,F,G,H,I,JB,C,E,F,H,J为demical类型
在有的数据行里,B,C,E,F,H,J中的某些为NULL我希望将NULL的update成0但是我不希望写成下面这样很多句子
update Table1 set B=0 where B is null
update Table1 set C=0 where C is null
update Table1 set E=0 where E is null
update Table1 set F=0 where F is null
....有没有简单点的语句????
里面有列A,B,C,D,E,F,G,H,I,JB,C,E,F,H,J为demical类型
在有的数据行里,B,C,E,F,H,J中的某些为NULL我希望将NULL的update成0但是我不希望写成下面这样很多句子
update Table1 set B=0 where B is null
update Table1 set C=0 where C is null
update Table1 set E=0 where E is null
update Table1 set F=0 where F is null
....有没有简单点的语句????
C=(case when C is null then 0 else C end),
E=(case when E is null then 0 else E end),
F=(case when F is null then 0 else F end)
c=case when c is null then 0 end,
d=case when d is null then 0 end
..
where B is null and C is null and E is null and F is null
FROM TB1 WHERE B IS NULL OR C IS NULL...
declare @table table
(B decimal(2,1),C decimal(2,1),E decimal(2,1),
F decimal(2,1),H decimal(2,1),J decimal(2,1))
insert into @table
select 1.1,1.2,1.4,1.5,1.9,2.1 union all
select null,3.2,null,9.1,null,9.1 union all
select 1.1,null,1.3,1.1,null,null union all
select 1.5,null,null,null,1,2.1update @table set B=isnull(B,0),
C=isnull(C,0),E=isnull(E,0),F=isnull(F,0),H=isnull(H,0),J=isnull(J,0)
select * from @table
C=(case when C is null then C=0 end),
E=(case when E is null then E=0 end),
F=(case when F is null then F=0 end)