SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Refreshing Views and Recompiling Stored Procs

By Jano Petras, 2007/04/20

Total article views: 422 | Views in the last 30 days: 29

When a table is modified by changing the order of fields or changing field type or adjusting field sizes etc, some of the dependent views (or views on views on views :)) may become invalid as they store some metadata in order to run more efficiently. These views would need to be refreshed with new metadata. Stored procedures store their execution plans as metadata as well, and it is a good idea to recompile them if the underlying tables have changed. This script goes through all views/stored procedures and markes them for recompilation or refreshes them. Use SQL Query analyser or SQL Server management studio to run it against a SQL Server 2000/2005 database. It will also notify you of any potential errors within the views.

By Jano Petras, 2007/04/20

Total article views: 422 | Views in the last 30 days: 29
Your response
 
 
Related tags
 
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com