Return @ErVar | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Return @ErVar

I notice a lot that at the end of stored procedures some people place error trapping like: SET @ErVar = @@Error
RETURN @ErVar Is this the same as: SET @ErVar = @@Error
IF @ErVar <> 0
pront "There’s been an error: " + @ErVar
RETURN ?? Thanks
http://www.sommarskog.se/error-handling-I.html
http://www.sqlteam.com/item.asp?ItemID=6881
http://www.sqlteam.com/item.asp?ItemID=2463 Satya SKJ
Microsoft SQL Server MVP
Contributing Editor & Forums Moderator
http://www.SQL-Server-Performance.Com
This posting is provided �AS IS� with no rights for the sake of knowledge sharing.
http://www.sommarskog.se/error-handling-II.html Madhivanan Failing to plan is Planning to fail
Just for completeness. In SQL Server 2005 you’ll find the new TRY…CATCH construct which lets you deal more easily with errors. —
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs
quote:Originally posted by sql_machine I notice a lot that at the end of stored procedures some people place error trapping like: SET @ErVar = @@Error
RETURN @ErVar Is this the same as: SET @ErVar = @@Error
IF @ErVar <> 0
pront "There’s been an error: " + @ErVar
RETURN ?? Thanks
————————–
Not same becoz first one irrespective of error numner it will come out of the SP where as second one error number is not equal then only it wll return. for better understanding check BOL -> Error Numbers and descriptions
SURYA
quote:Originally posted by sql_machine I notice a lot that at the end of stored procedures some people place error trapping like: SET @ErVar = @@Error
RETURN @ErVar Is this the same as: SET @ErVar = @@Error
IF @ErVar <> 0
pront "There’s been an error: " + @ErVar
RETURN ?? Thanks

In our Project we had these type return.
Because we had separate error table.
From there front end people display error message based on the error number coming from stored procedure. Ganesan B.
Well defined problem is half way solved.
]]>