先放一放。呵呵。
declare @newstr varchar(100)
set @newstr='无' --新字符
declare @table varchar(256)
set @table='year2004' --表
declare @upcol varchar(8000)
declare tb cursor local for
select upcol='update ['+b.name+'] set ['+a.name+']='''+@newstr+''' where ['+a.name+'] is null'
from syscolumns a join sysobjects b on a.id=b.id
where b.xtype='U' and a.status>=0
and a.xusertype in(175,239,231,167) and b.name=@table
open tb
fetch next from tb into @upcol
while @@fetch_status=0
begin
exec(@upcol)
fetch next from tb into @upcol
end
close tb
deallocate tb
set @newstr='无' --新字符
declare @table varchar(256)
set @table='year2004' --表
declare @upcol varchar(8000)
declare tb cursor local for
select upcol='update ['+b.name+'] set ['+a.name+']='''+@newstr+''' where ['+a.name+'] is null'
from syscolumns a join sysobjects b on a.id=b.id
where b.xtype='U' and a.status>=0
and a.xusertype in(175,239,231,167) and b.name=@table
open tb
fetch next from tb into @upcol
while @@fetch_status=0
begin
exec(@upcol)
fetch next from tb into @upcol
end
close tb
deallocate tb