您省事,我来费事儿吧,写了一个存储过程,只需指定表名,就可以
将指定表所有为空的字段(根据字段数据类型)设置为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 '表名'
爽完了别忘记多加些分噢
=============
只顾爽了吗?
温馨提示:答案为网友推荐,仅供参考