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 712929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:54:16+00:00 2026-05-14T04:54:16+00:00

Could anyone point exactly where MSDN says thet every user stored procedure returns 0

  • 0

Could anyone point exactly where MSDN says thet every user stored procedure returns 0 by default if no error happens? In other words, could I be sure that example code given below when being a stored procedure

IF someStatement
BEGIN
  RETURN 1
END

should always return zero if someStatement is false and no error occurs?

I know that it actually works this way, but I failed to find any explicit statement about this from Microsoft.

  • 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-14T04:54:16+00:00Added an answer on May 14, 2026 at 4:54 am

    It looks like once upon a time the return value may have meant something (see reference of pre SQL 2000 BOL return value article) prior to SQL Server 2000.
    I checked around to see if I could find a listing of these original return codes specifically for MS SQL, and found the following (I don’t know its authenticity though, and it doesn’t actually list the values).

    So, after reading all of these articles it looks like @return_status is a parameter that is ALWAYS returned when a stored procedure is executed (even if you do not use it). According to the RETURN Books online article the return code CANNOT be null.

    When used with a stored procedure,
    RETURN cannot return a null value. If
    a procedure tries to return a null
    value (for example, using RETURN
    @status when @status is NULL), a
    warning message is generated and a
    value of 0 is returned.

    Running the following T-SQL definitely shows this,

    create Procedure Test
    as
    begin
    DECLARE @RTN integer
    Return @RTN
    END
    GO
    
    Exec Test
    GO
    
    Drop Procedure Test
    GO
    

    You’ll receive

    The 'Test' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.
    

    In the end it looks like the answer is because @return_status cannot be null (being 0 when not set, or set to NULL)…

    As for the error codes mentioned in the supposed BOL article for SQL 7.0, my guess would be an old hold over from Sybase… Sybase 5.0 Manual

    Kris

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anyone point me to a resource that explains WCF with pictures and simple
Could anyone could point me to some code/give me ideas on how to create
I was wondering if anyone could point to an Open Source date utility class
Can anyone point me in the direction of how I could get a NUnit
I was wondering if anyone could give me an example or point me to
Could anyone explain with some examples when it is better to call functions by
Could anyone recommend a good BAML Decompiler / Viewer besides BAML Viewer plugin for
Could anyone suggest a good packet sniffer class for c++? Looking for a easy
Could anyone explain me why: function doAjax() { var xmlHttpReq = false; try {
It used to be that you could load Typus routes exactly where you needed

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.