We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

@@error not working

amitabh04
amitabh04 asked
on
Medium Priority
261 Views
Last Modified: 2012-05-11
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

Comment
Watch Question

Commented:
Can you please share a sample code and what exactly the error is...
Alpesh PatelSolution Architect at TCS (SAFe®Agilist, TOGAF® Foundation, PSM I®, MCP, MCSD)
CERTIFIED EXPERT

Commented:
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

Author

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.
CERTIFIED EXPERT
Top Expert 2012
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.