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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-12-11 : 07:55:16
|
| MM writes "Hi,Please see the code block written below. Is there any way by which I can handle/trap the error that is generated when you execute this code block.create table test (intCol int)godeclare @ins_error intbegin traninsert test (intCol)select 'a'select @ins_error = @@errorif @ins_error <> 0begin print 'error occurred' rollback tranendelsebegin print 'no error' commit tranendThis code block seems to be generating a fatal error. Is there a way to trap such an error? I want to log all the errors that occur while executing my stored procedure, but when the above error is generated I'm not able to log it in a table.Thanks." |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-12-11 : 08:04:36
|
you can use the raiserror() function or return the error code with an output paramterer.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
|
|
|