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')
1,您建立的表没有主键,删除不删除都无所谓 2,可以先导出字段名(右键点击要操作的table--所有任务--生成sql脚本) 然后按“海之韵”的建议:建立一个job,可以定期执行 delete yourtable where 列名 is null and 列名 is null and ..
你的意思我明白,你不想经常写很长的代码。 你可以编写一个存储过程,执行它就行了。 create proc p1 as delete yourtable where col is null and col1 is null..... return go exec p1
这个查询也许对你有帮助 select s.name 列名, s.scale 预设值 from syscolumns s ,sysobjects t where s.id=t.id and t.name=表明 做一个游标,结合上面的说法就可以实现了
你的数据库服务器-》企业管理器-》管理-》SQL Server 代理-》作业-》新建作业,按照要求填就可以了,在“步骤”的“命令”中填写你要执行的存储过程或语句,在“调度”里面填写什么时间执行 delete yourtable where col is null and col1 is null and ......
delete from tablename where 字段1=null or 字段2=null or 字段3=null....
from sysobjects t1,syscolumns t2 where t1.id=t2.id and t1.name='pub_code'
and t2.name not in ('DT')
2,可以先导出字段名(右键点击要操作的table--所有任务--生成sql脚本)
然后按“海之韵”的建议:建立一个job,可以定期执行
delete yourtable where 列名 is null and 列名 is null and ..
你可以编写一个存储过程,执行它就行了。
create proc p1
as
delete yourtable where col is null and col1 is null.....
return
go
exec p1
select s.name 列名, s.scale 预设值
from syscolumns s ,sysobjects t
where
s.id=t.id and t.name=表明
做一个游标,结合上面的说法就可以实现了
delete yourtable where col is null and col1 is null and ......