0

I am working with a large group of stored procedures (~300) in SQL Server 2012 Web Edition and I need to enable/disable some of the stored procedures at various times.

Is there a way to create a sub-folder under "Programmability" in SQL Server Management Studio to place inactive stored procedures in? If not, is there an option to enable/disable a specific stored procedure without removing it from the database? Since I frequently need to enable/disable I would rather not remove the procedure and then re-script it when it is needed?

webworm
  • 10,587
  • 33
  • 120
  • 217

5 Answers5

4

Create those stored procedure in a separate schema (use CREATE SCHEMA) and then GRANT or REVOKE execution right on all stored procedures in that schema for the users in charge.

bjnr
  • 3,353
  • 1
  • 18
  • 32
1

As a suggestion, you can have contract in naming for example spTest is enables and spTest_Disabled is the same one which is disabled, so you can write another storedprocedue with this sugnature spChangeSpStatus(spName,state) this sp uses sp_rename to rename the procedure to new one,(I mean adding _disabled to its name or remove _disabled form the name)

I hope this helps

Reza
  • 18,865
  • 13
  • 88
  • 163
1

You can't create a subfolder, but can create another schema. Name it whatever you like (say inactive) and set permissions on it appropriately.

Then write a script to move objects from the working schema (say dbo) to inactive:

alter schema inactive transfer dbo.proc
dean
  • 9,960
  • 2
  • 25
  • 26
1

There is an inexpensive tool called SQLTreeo that allows you to create folders in the Object Explorer. If I remember correctly, there are two modes of operation, one that allows each user with the tool to have their individual folder structure, and another that imposes a common folder structure appear on all machines that have SQLTreeo installed.

David Atkinson
  • 5,759
  • 2
  • 28
  • 35
0

Create a new table to manage your SP, and in each SP just add an IF that always ask for the table created dbo.ManagerSP if that sp is Active=true, if true the SP runs,,,if not,,,not runs,,

And with that for control all your SP just need run an UPDATE of active status in dbo.ManagerSP