如何在存储过程中执行此操作(SQL 2005):
count = select count(*) from table1 where line like '%success%'
if count > 0:
delete from table1 where not line like '%success%'
感谢您的帮助。今天我的谷歌技能真的让我失望: - (
答案 0 :(得分:5)
我会这样写的
if exist (select 1 from table1 where line like '%success%')
begin
delete from table1 where line not like '%success%'
end
答案 1 :(得分:5)
因此,如果有line
成功的行,那么删除line
不成功的行吗?
IF EXISTS (SELECT * from table1 where line like '%success%')
delete from table1 where line NOT like '%success%'
答案 2 :(得分:1)
我根本不会保留支票。检查的目的是什么?
只需使用删除查询和where子句。