怎样将表中的NULL改为空

我有一张SQL表,里面有相当多的字段,每个字段中都有部分数据为NULL,请问我怎样通过一条SQL语句实现将整个表中的所有为NULL的改为空呢?
update 表名 set 字段名='' where 字段名 is NULL
只能一列一列的改,但是字段实在太多了。。。如果用这句改到猴年去啊?
请大侠们帮帮忙!

您省事,我来费事儿吧,写了一个存储过程,只需指定表名,就可以
将指定表所有为空的字段(根据字段数据类型)设置为0或0长度空格的存储过程。
create procedure fill_null
@tablename varchar(100) --表名
as
declare @colname varchar(100)
declare col_cur cursor for select c.name from syscolumns c,sysobjects o where c.id=o.id and o.name=@tablename
open col_cur
fetch next from col_cur into @colname
while @@fetch_status!=-1
begin
exec ('update '+@tablename+' set '+@colname+'='''' where '+@colname+' is null' )
fetch next from col_cur into @colname
end
close col_cur
deallocate col_cur
go

试一下吧,很爽噢:
exec fill_null '表名'
爽完了别忘记多加些分噢
=============
只顾爽了吗?
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-11-26
会编程的话,写个小程序很容易搞定了
第2个回答  2008-11-27
囧,,,,WHITE_WIN 的方法,楼主爽了没有啊。我收藏答案啊。
相似回答