delete from  tablename where 某字段=null

解决方案 »

  1.   

    delete yourtable where col is null and col1 is null新建job把上面语句加进去
      

  2.   

    我的意思是所有字段、或除DT字段外的所有字段为空时删除该行,本表的字段比较多,不想一一的写等于NULL,有方便一点的法子吗?
      

  3.   

    select 'delete from 表名 where '+t2.name +' is null'
     from sysobjects t1,syscolumns t2 where t1.id=t2.id and t1.name='pub_code'
    and t2.name not in ('DT')
      

  4.   

    1,您建立的表没有主键,删除不删除都无所谓
    2,可以先导出字段名(右键点击要操作的table--所有任务--生成sql脚本)
      然后按“海之韵”的建议:建立一个job,可以定期执行
       delete yourtable where 列名 is null and 列名 is null and ..
      

  5.   

    你的意思我明白,你不想经常写很长的代码。
    你可以编写一个存储过程,执行它就行了。
    create proc p1
    as
    delete yourtable where col is null and col1 is null.....
    return
    go
    exec p1
      

  6.   

    这个查询也许对你有帮助
    select s.name 列名, s.scale 预设值 
    from syscolumns s ,sysobjects t
    where 
    s.id=t.id and t.name=表明 
    做一个游标,结合上面的说法就可以实现了
      

  7.   

    你的数据库服务器-》企业管理器-》管理-》SQL Server 代理-》作业-》新建作业,按照要求填就可以了,在“步骤”的“命令”中填写你要执行的存储过程或语句,在“调度”里面填写什么时间执行
    delete yourtable where col is null and col1 is null and ......
      

  8.   

    delete from  tablename where 字段1=null or 字段2=null or 字段3=null....
      

  9.   

    pengdali(大力 V3.0) 回来了,跑啊`~~呵呵。