[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

@@error not working

Hi,
   The @@error does not return error code when doing single insert. The query anayzer editor does not seems to have any special settings. The sqlserver is 2000.

Thanks a lot

0
amitabh04
Asked:
amitabh04
1 Solution
 
kamindaCommented:
Can you please share a sample code and what exactly the error is...
0
 
Alpesh PatelAssistant ConsultantCommented:
When you use the @@error, please take it in other local variable. Because after a single use of @@error will be flushed automatically.

Set @Errorval = @@error
0
 
amitabh04Author Commented:
Hi,
  The code is like the folowing and still it does not work. I am trying to catch constraint error.

insert into b..tab1 select x, y from tab2

set @err = @@error

if ( @err > 0 ) then

...
end

Thanks.
0
 
Anthony PerkinsCommented:
If that was in fact your code, then there was no error.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Tackle projects and never again get stuck behind a technical roadblock.
Join Now