In a stored procedure how to run a query and conditionally do something?

IF EXISTS (SELECT * from table1 where line like '%success%') delete from table1 where line NOT like '%success%.

I would write that this way if exist (select 1 from table1 where line like '%success%') begin delete from table1 where line not like '%success%' end.

I would not keep the check at all. What is the purpose of that check? Just use the delete query along with the where clause.

I assume the table is a log of some sort, so if the process ended without a "success" message you can find out what went wrong. On the other hand, when there is a "success" message he's not interested in the other messages, only that it was successful. That's my guess.

– Tony May 11 '10 at 15:12.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions