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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Capturing @@Error from within EXEC(@sqlstring)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-11-05 : 13:53:19
Ralph writes "I have a process that builds and executes dynamic SQL strings. This process use to be driven by VB/ADO Inserts and any error would flush back to the VB app where I handled/logged. Now the process is driven by a scheduled SQL Task (job calls an SP). I can not trap the errors that happen within the executed string. Typically these are violation of a Unique Constraint or Foreign Key violation, levels 14 and 16 respectively. These errors terminate the entire process, including the originating SP. With VB/ADO, I use to be able to keep rolling after an error. How can I trap an error when I do an EXEC(@sqlstring)? I want to log the error (created sp_Error_Logger) and I want to skip offending Insert and continue with next."
   

- Advertisement -