求一个存储过程的语句
假设表A中有b,c,d三个字段100条纪录,用一个存储过程判断b,c两个字段是否为空,如果为空,则将其设为0。
------解决方案--------------------.....我郁闷了
select a,isnull(b,0) b,isnull(c,0) c from 表
update 表 set b=0 where b is null
update 表 set c=0 where c is null
先不说存储过程,是想要这样的嘛 "?
------解决方案--------------------create procedure roy
as
begin
if exists(select 1 from tbl where b is null )
update a set b=0 where b is null
if exists(select 1 from tbl where C is null )
update a set C=0 where C is null
end
------解决方案--------------------create proc sp_test
as
begin
update A
set b = isnull(b, 0), c = isnull(c, 0)
where b is null or c is null
end