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 2008 Forums
 Transact-SQL (2008)
 Error Codes for Custom messages

Author  Topic 

Sql_forum
Yak Posting Veteran

50 Posts

Posted - 2011-11-28 : 04:57:58
What is the error code range that i can use for custom error messages in sql?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 05:03:38
Usually values greater than 50000 are given for custom message numbers

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

7siva7
Starting Member

28 Posts

Posted - 2011-11-28 : 05:07:27
How can we use custom error messages ...can you give me a syntax or example code?

HI
Go to Top of Page

Sql_forum
Yak Posting Veteran

50 Posts

Posted - 2011-11-28 : 05:13:50
RAISERROR (50005,16,1)

Is the above way using RAISERROR is correct??
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 07:27:16
quote:
Originally posted by Sql_forum

RAISERROR (50005,16,1)

Is the above way using RAISERROR is correct??


yes it is

and message can be added before using sp_addmessage

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Sql_forum
Yak Posting Veteran

50 Posts

Posted - 2011-11-29 : 06:53:02
What if i didn't add message?
I m trying to execute Procedure in C#... but it is not returnig me error code
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-29 : 06:57:27
quote:
Originally posted by Sql_forum

What if i didn't add message?
I m trying to execute Procedure in C#... but it is not returnig me error code


If you didnt add message already, you need to explicitly include it in RAISERROR

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -