Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Blocking Stored Procedures


Blocking Stored Procedures

Author
Message
cindy.hutchins
cindy.hutchins
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
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.
Tommy Bollhofer
Tommy Bollhofer
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1166 Visits: 3359
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

Follow @sqlscribe
Carleton
Carleton
SSC-Enthusiastic
SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)

Group: General Forum Members
Points: 158 Visits: 3892
If your pretty sure this procedure is not needed anymore and it is a security risk, you probably should drop it:


DROP PROCEDURE [ProcedureName]


arun.sas
arun.sas
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1237 Visits: 3493
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


Carleton
Carleton
SSC-Enthusiastic
SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)

Group: General Forum Members
Points: 158 Visits: 3892
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
cindy.hutchins
cindy.hutchins
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 21
I ran the alter procedure and it worked very well for us. Thank you for all of your help.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search