Solved

SQL Return Code - 6

Posted on 2013-10-31
3
576 Views
Last Modified: 2013-11-06
I got a -6 as a return code from an SP but I have no idea what -6 is and cannot find a reference to it. Can anyone shed some light?

Thanks,
Dean
0
Comment
Question by:dthansen
3 Comments
 
LVL 8

Accepted Solution

by:
Chris Wong earned 500 total points
ID: 39615700
If you have a RETURN statement with an explicit return value, that is of course the return value.

But if there is no RETURN statement, but an error occurs during execution, the return value is 10 minus the severity level of the error. Division by zero is level 16, thus the return value is -6. Permissions errors are typical level 14, thus the return value is -4.

As you may guess this is not terribly useful, but this: 0 is success, and everything else is an error.

<competing site link removed - GaryC123 - 1st Nov>
0
 
LVL 10

Expert Comment

by:HuaMinChen
ID: 39615789
Try to read the codes of the SP for the details of the return parameter.
0
 
LVL 11

Expert Comment

by:Louis01
ID: 39616145
I'd suggest you update the SP to show more about the error.

For instance:

BEGIN TRY
    -- Generate a divide-by-zero error.
    SELECT 1/0;
END TRY
BEGIN CATCH
    SELECT
        ERROR_NUMBER() AS ErrorNumber
        ,ERROR_SEVERITY() AS ErrorSeverity
        ,ERROR_STATE() AS ErrorState
        ,ERROR_PROCEDURE() AS ErrorProcedure
        ,ERROR_LINE() AS ErrorLine
        ,ERROR_MESSAGE() AS ErrorMessage;
END CATCH;

Open in new window

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

777 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