[thelist] SQL Server & Stored Procedures

rudy r937 at interlog.com
Tue Oct 30 09:04:52 CST 2001

> 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) ...

yikes, dex, that's scary

i've never needed @@rowcount, but if it's a global variable, then yeah, it
would change unpredictably if (ha!) there are other threads running...

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

hey, thanks for the implied compliment, but, contrary to apparent
widespread belief, i do not know the right way to do a whole range of
things, including stored procedures...

this would be my attempt --

  select @arethereanytodelete= count(*)
      from news_comments dev
     where comment_id = @comment_id
  if @arethereanytodelete > 0
         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


More information about the thelist mailing list