Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


SQL Server 2000 ErrorMessages vs SQL Server 2005

Posted on 2007-11-25
Medium Priority
Last Modified: 2010-03-19
In sqlserver 2000  I check @@Error after each and very SQL Statement and if > 0 return -1

In Current 2005 in Catch Block  I use ERROR_MESSAGE (System function) to catch error and Raise it back to my client.

In SQL Server 2000  Cant we use ERRORMESSAGE (Detailed Description of Error like in SQLServer 2005) in a stored procedure...
Question by:dotnet0824
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
LVL 15

Assisted Solution

spprivate earned 200 total points
ID: 20345753
This is a goodway to handle errors with detailed messages
LVL 31

Accepted Solution

James Murrell earned 600 total points
ID: 20346290

Author Comment

ID: 20346708
so in sql server 2000 we have to create our own custom message descriptions to give a clear picture of the Error by adding to to sp_addmessage

But in SQL Server 2005 we dont need to do anything of that sort and its pretty straight forward using
inbuilt system function ERROR_Message ......Am I right?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 31

Expert Comment

by:James Murrell
ID: 20346845
as far as i am aware yes...
LVL 18

Assisted Solution

Yveau earned 200 total points
ID: 20348876
Yep, in the catch block just use the ERROR_MESSAGE() function to retrieve the error that caused that fact that the catch block was entered. So no more @@Error catching after each SQL statement, just run some code in a try block and do the error tracking and handling in the catch block with the above mentioned function.

Also these functions can add some nice functionality:
        ERROR_NUMBER() AS ErrorNumber,
        ERROR_SEVERITY() AS ErrorSeverity,
        ERROR_STATE() AS ErrorState,
        ERROR_PROCEDURE() AS ErrorProcedure,
        ERROR_LINE() AS ErrorLine,
        ERROR_MESSAGE() AS ErrorMessage;
(also in the catch block !)

Hope this helps ...

Author Comment

ID: 20351990
So my final quesiton is this... IN Sql Server 2000 There is no way to catch and use RaisERROR to the client directly like u do in SQL Server 2005 ERROR_Message............. So only ErrorNumbers can be Raised in SQL Server 2000  ........So no message information being raised
LVL 31

Expert Comment

by:James Murrell
ID: 20352076
I think you are correct with that assumption
LVL 18

Expert Comment

ID: 20352219
Indeed, that is correct ... when you do not declare the user messages first.

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question