blog.jj5.net (2003 to 2005)

Using @@ERROR and @@ROWCOUNT in SQL Server

Tue Jun 22 20:16:00 UTC+1000 2004

Categories:

OK, if you read @@ERROR then @@ROWCOUNT is reset.

If you read @@ROWCOUNT then @@ERROR is reset.

If you want to know the value of both @@ERROR and @@ROWCOUNT then it might seem like you're kind of shagged.

Well, you would be, except if you read them both at the same time! ;)

Like so:

SELECT @err = @@ERROR, @rc = @@ROWCOUNT

Just nicely thank you.

John.

(If you haven't danced yet, then what the fuck did you come for!?)


Copyright © 2003-2005 John Elliot