Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6535591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:23:29+00:00 2026-05-25T10:23:29+00:00

I have a stored procedure on a hosted SQL 2008 instance. In these stored

  • 0

I have a stored procedure on a hosted SQL 2008 instance. In these stored procedures is logic checking for error. I then return an error code using RAISERROR(#####, ##, ###) if there is a problem. This works well enough, but there is a problem with catching such an error.

In Visual Studio 2010 I can catch the error with the correct Class and State, but never the correct Number. I will get a Message like the following in the exception:

Error #####, severity ##, state ###, was raised, but no message with that error number was found in sys.message. If error is larger than 50000, make sure the user-defined message is added using sp_addmessage.

So clearly the error is being raised correctly from the procedure, but the Number returned is always 18054. What am I doing wrong? I don’t care what the text of the message is, and I don’t have permission to run sp_addmessage anyway. However, I would like Number to be correct so I can properly catch the error in my application and handle it properly.

In case it matters, I’m calling the procedure using EF4.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:23:29+00:00Added an answer on May 25, 2026 at 10:23 am

    Your error isn’t being raised correctly. The error you’re actually getting, 18054, is a system error which pretty much says,

    “Hey, you called raiserror() with an error number which doesn’t appear in [sys].[messages]!”

    If you don’t have access to add records to [sys].[messages] just specify your error number in the message text (msdn):

    RAISERROR (N'321433', -- Message text. Parse as int in exception handling.
               10, -- Severity
               1) -- State
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure in SQL Server 2008 that will insert a record
I have a stored procedure which is building a dynamic sql query and then
I have a stored procedure in SQL 2005. The Stored Procedure is actually creating
I have stored procedures in SQL Server T-SQL that are called from .NET within
I have stored procedures (they accept parameters) that return multiple result sets and I'd
I have a stored procedure in SQL Server 2000 that performs a search based
I have a stored procedure in an old SQL 2000 database that takes a
I have a stored procedure in SQL 2005 that calculates distance using the Haversine
I have a stored procedure in sql server that returns xml. The problem I'm
I have a stored procedure which has 4000 lines of code it is in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.