Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vgr.raju
Yak Posting Veteran
95 Posts |
Posted - 2007-08-06 : 16:12:42
|
| Hi, I am using the TRY/CATCH BLOCK TO TRAP THE ERRORS IN MY SQL SCRIPT.Within my Try block,I am calling number of stored procedures and the error occurs at line number 15.But my catch block reports the error occured in line 0.I am confused and googled it for a while.It should return the line number where the error occured in try block.But its not returning the right line number.Your help would be much appreciated.My statement looks like this.begin tryexec sp1exec sp2exec 2p3exec sp4 ---etc error occurs at line number 15end try BEGIN CATCH PRINT 'Error Detected' SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, ERROR_STATE() AS ErrorState, ERROR_PROCEDURE() AS ErrorProcedure, ERROR_LINE() AS ErrorLine, ERROR_MESSAGE() AS ErrorMessage;END CATCHThanks,RajuThanks!Rajuhttp://rajusqlblog.blogspot.com/ |
|
|
rudesyle
Posting Yak Master
110 Posts |
Posted - 2007-08-07 : 10:26:47
|
| Please note that the line number that is captured is the line number from WITHIN the stored procedure, and not the line where you called it. |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-08-07 : 10:27:22
|
| try just exec BombingSPName alone inside the try block and see what error_line you get[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|