Friday, September 19, 2008

Think about what you are doing!

Last statement in a stored procedure running in production:

SELECT @ReturnStatus = @@ERROR
IF(@ReturnStatus <> 0)
   RETURN (@ReturnStatus)

Making things as simple as possible isn't just for self-congratulatory back-patting. It's because the next time you're looking at the code it will make it easier to understand what it's doing. So let's make it simple:

RETURN @@ERROR;