Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Blocking Stored Procedures Expand / Collapse
Author
Message
Posted Friday, September 18, 2009 9:19 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, September 21, 2009 7:34 AM
Points: 17, Visits: 21
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.
Post #790468
Posted Friday, September 18, 2009 9:37 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:39 AM
Points: 1,157, Visits: 3,264
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



Tommy

Post #790494
Posted Friday, September 18, 2009 11:59 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, June 8, 2012 12:30 AM
Points: 150, Visits: 3,892
If your pretty sure this procedure is not needed anymore and it is a security risk, you probably should drop it:

DROP PROCEDURE [ProcedureName]

Post #790751
Posted Saturday, September 19, 2009 12:17 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, April 19, 2012 10:25 PM
Points: 1,229, Visits: 3,483
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

Post #790754
Posted Saturday, September 19, 2009 12:24 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, June 8, 2012 12:30 AM
Points: 150, Visits: 3,892
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
Post #790756
Posted Monday, September 21, 2009 7:35 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, September 21, 2009 7:34 AM
Points: 17, Visits: 21
I ran the alter procedure and it worked very well for us. Thank you for all of your help.
Post #791111
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse