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

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Drop and re-create all stored procedures or views

By Cade Bryant,

There are times when you may need to drop and re-create all stored procedures and/or views in your database. 

For example, in cases where procedures or views are causing blocked locks or other performance problems, a recent article (http://www.sswug.org/see.asp?s=1166&id=13448) suggested dropping/re-creating procedures and views after a service pack has been installed. 

The installation of a service pack (or other significant configuration alteration) often results in performance problems (acording to this article), which can be resolved in some cases by dropping/re-creating objects.

However, manually dropping and re-creating all objects can be tedious, so I decided to create a more automated way of doing it.  

The following stored procedure, drop_and_recreate_all, takes a single parameter representing the object type, and generates a script for dropping all objects of that type (make sure that "Results in Text" is selected).  You can then paste the results into a new Query Analyzer window and execute it.  

Total article views: 1129 | Views in the last 30 days: 4
 
Related Articles
FORUM

Creating view from stored procedure results

Creating view from stored procedure results

FORUM

Create procedure and filter the result

Create procedure and filter the result

FORUM

create Procedure within Procedure

create Procedure within Procedure

FORUM

store procedure result to excel

store procedure result to excel

FORUM

Creating Database Objects from a Trigger-invoked stored procedure....

I am trying to create job-specific database objects (views, sp) after creating the db and tables suc...

 
Contribute