Blocking Stored Procedures

  • Our company has had many consultants come in over the last few years and apparently one of them wrote a stored procedure that hasn't been run since 06. How can I block access to keep anyone from running this stored procedure again.

  • cindy.hutchins (9/18/2009)


    Our company has had many consultants come in over the last few years and apparently one of them wrote a stored procedure that hasn't been run since 06. How can I block access to keep anyone from running this stored procedure again.

    i.e.

    DENY EXECUTE,VIEW DEFINITION ON usp_MyProc TO SomeDatabaseRole

  • If your pretty sure this procedure is not needed anymore and it is a security risk, you probably should drop it:

    DROP PROCEDURE [ProcedureName]

  • More safe is making a return statement with desired messages in the SP,then only the users/sa/dba understand the causes.

    ALTER PROCEDURE DBO.MYPROCEDURE

    --

    --

    --

    as

    begin

    begin

    raiserror ('your message why its blocked to execute, any specific reason(s)',16,1)

    return

    END

    --

    --

    --

    END

  • I like arun.sas' suggestion. If you need to keep the code in the sproc, you could just add what arun.sas suggested to the top of the procedure thereby 1) preventing it from being executed; 2) retaining the code in case in needs to be utilized; 3) provides a useful error message if it is attempted to be executed.

    Cheers,

    Carleton

  • I ran the alter procedure and it worked very well for us. Thank you for all of your help.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply