首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

存储过程的语句

2012-01-08 
求一个存储过程的语句假设表A中有b,c,d三个字段100条纪录,用一个存储过程判断b,c两个字段是否为空,如果为

求一个存储过程的语句
假设表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

热点排行