update 表 set 列1=isnull(列1,''),列2=isnull(列2,'')

解决方案 »

  1.   

    update tablename set 列名='' where 列名 is null
      

  2.   

    好象在sysobjects表中可以查询到哪些表需要更改,
    你可以写一段sql脚本,自动生成update语句即可。
      

  3.   

    设计数据库时应该尽量避免空字段,设置为Default
      

  4.   

    可以用循环来执行update,下次创建表的时候注意加上
    default为‘’就好了。
      

  5.   

    have a try:declare @colname varchar(10)
    declare cur cursor for
    select c.name from syscolumns c ,sysobjects o where 
    o.id=c.id and o.id=object_id('authors')
    declare @str varchar(100)
    select @str='''aaa'''
    open cur
    fetch next  from cur into @colname
    begin
    exec('update authors set ' +@colname +' =isnull( ' +@colname+'  ,'+@str+')')
    end
    while @@fetch_status=0
    beginexec('update authors set ' +@colname +' =isnull( ' +@colname+'  ,'+@str+')')
    fetch next from cur  into @colname 
    endclose cur
    deallocate cur
      

  6.   

    利用sysobjects 找到你要的表
    利用syscolumns 找到你要的列
    利用SysTypes 找到你要的varchar类型
    然后根据大力的方法解决就可以了.
    其实不太麻烦!
      

  7.   

    UPDATE 表名 SET 字段=IIF(ISNULL(字段 ),‘’,字段 )
      

  8.   

    呵呵
    谢谢大家,因为我在应用程序里有时需要删除一个值,删除之后就在SQL里成了<NULL>了,不过我现在根据大家的意见已经实现了所有字段的清空,感谢大家!