You must Sign In to post a response.
  • Category: SQL Server

    Avoid Stored Procedures not returning a status value

    Hi,

    We are using some third party tool to find the all violations in inside code of stored proc,tables,functions,views.

    This is "How to Avoid Stored Procedures not returning a status value." one of the violation.

    Below i Pasted the Example CODE.

    in my point
    1) select query we can use transaction is this advisable.
    2) using return 0 is success return 1 is failure what is usage of using Return 0 or 1 in inside SP's

    ALTER PROCEDURE sample
    AS
    BEGIN
    BEGIN TRY
    BEGIN TRANSACTION

    SELECT *
    FROM Account WITH (NOLOCK)

    COMMIT TRANSACTION

    RETURN 0
    END TRY

    BEGIN CATCH
    IF @@ERROR > 0
    BEGIN
    ROLLBACK TRANSACTION;

    SELECT N'Error in Sample ' + ERROR_MESSAGE()

    RETURN 1
    END
    END CATCH
    END

    With Regards,
    Prabu.L
  • #762077
    Hi,

    Can you please explain what exactly you are looking for? If you wanted to avoid stored procedure then just don't call that. Not sure where you wanted to use this code and why you wanted to use. Please explain properly.


    Regards,
    Asheej T K
    Microsoft MVP[ASP.NET/IIS]
    DotNetSpider MVM

  • #762081
    Hi,

    I request to all while raise a question please follow the instruction provided by our webmasters. So, that one of our experts will give some suggestions to fix that.

    As per your post we can't help you, the content is not understandable manner, please edit your post and re-post it again.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762097
    Hi
    Prabhu

    Can you share your Stored Procedure then we will check and fixed easily and quick response to you.

    then did you return status value means you need remove that and use your stored procedure.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments