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 |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-08-16 : 18:48:50
|
| I was trying to capture the error when an insert and update happens.Here emp_id is an int and the value passed is string which automatically gives an error and I can't capture the error with this query.Is there any wayDECLARE @error_int intINSERT INTO tbl_emp_details (emp_id,emp_name)VALUES('john','Hari')SELECT @error_int = @@error IF @error_int <>0 BEGIN PRINT 'TEST' END |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-08-16 : 19:24:09
|
| You can't capture the error when it's this type of error. It just blows out of the batch. In the next version of SQL Server, you will be able to with a TRY..CATCH.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-08-16 : 19:39:30
|
| so what types of error can I capture with the @@error command.will raiserror help.So if I want to capture an error description during an transaction what should I do |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-08-16 : 19:46:53
|
| Do it at the application. :) You can also capture failure in jobs, DTS packages, etc. The @@error will capture all kinds of errors. Type in @@ERROR in Books Online to research it on your own. After that, let us know if you have any questions.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|