Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 1068 | Views in the last 30 days: 5
 
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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones