[thelist] SQL Server & Stored Procedures

Scott Dexter sgd at ti3.com
Tue Oct 30 08:18:43 CST 2001


> 
> DELETE FROM NEWS_COMMENTS_DEV WHERE comment_id = @comment_id UPDATE
> NEWS_ARTICLES_DEV SET a_comments = a_comments - 1 WHERE news_id =
> @news_id 
> 
> I would like to execute the UPDATE statement only if the 
> DELETE command
> managed to delete something. So what's the best way to do this?
> 

You could check out writing a trigger that'd fire on the delete ... I'm
not too hip on the @@rowcount property because it is a server global,
and we've (here at work) have seen it be not so reliable in high traffic
(it will be the value of another operation somewhere else in the db
server, not of the statement you just fired) ... you could also do
something like this (expensive):

delete...
if not exists (select comment_id from news_comments) then
	update ...

Rudy, any other ideas (iow, the right way to do this?)

sgd




More information about the thelist mailing list