日期:2014-05-17 浏览次数:21218 次
update tb set col='NN' where col='' or col is NULL
------解决方案--------------------
declare @colname varchar(100), @sql varchar(3000) set @sql='' select @colname=name from syscolumns where id=object_id('tb') set @sql='update tb set'+''+@colname+''+'=NN'+'where col='' or col is NULL' exec (@sql)
------解决方案--------------------
declare @colname varchar(100), @sql varchar(8000) set @sql='' declare cur_tbcolumn cursor for select name from syscolumns where id=object_id('tb') fetch next from cur_tbcolumn while @@fetch_status=0 begin set @sql='update tb set '+@colname+'=''NN'''+'where '+@colname+'='''' or '+@colname+' is NULL' exec (@sql) set @sql='' fetch next from cur_tbcolumn end
------解决方案--------------------
declare @colname varchar(100), @sql varchar(8000) set @sql='' declare cur_tbcolumn cursor for select name from syscolumns where id=object_id('tb') OPEN cur_tbcolumn fetch next from cur_tbcolumn while @@fetch_status=0 begin set @sql='update tb set '+@colname+'=''NN'''+'where '+@colname+'='''' or '+@colname+' is NULL' exec (@sql) set @sql='' fetch next from cur_tbcolumn end