Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a OPENQUERY linking to an Oracle server that is failing. (I can't make any changes on the oracle server)

But when it returns the error string it is cut short because it returns the query in the error string and the query is longer than 4000 characters, and because ERROR_MESSAGE() is of type nvarchar(4000) the part of the error I need is missing.

Is there some way to get the remained of the string before it is truncated or is it saved some where else?

share|improve this question
you can try to run the query from OPENQUERY directly in the Oracle's SQL*Plus, or you can try to reduce the SQL statement to find where the error is – cha May 20 '14 at 3:41
Thanks for the suggestion unfortunately this error is an intermittent error and it is only occurring when I run it in a larger script that takes about 6 hours to run through. I have tried removing all the whitespace from the query but this wasn't enough and I also tried reducing the complexity of the query just for testing to make it shorter but this got rid of the error. I think the error must be because of the load on the server but I would really like to be able to get the error message so I can see what it says... – user802599 May 20 '14 at 23:21
What about testing for error_number() – cha May 21 '14 at 6:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.