We needed a hands off method to refresh all of the data periodically. So, I created a script. It’s relatively clean, but I didn’t go for the style points. You’ll find good use of dynamic SQL and also nested cursors in this one. (If anyone can come up with a way to get rid of the temp table, I’m all ears. — Already tried the exec (declare cursor…) method and it didn’t work. Also the use database method to change context doesn’t work either.) Since this thing requires passwords to be tossed into the code, create this proc with encryption. (Make sure to keep this text copy as you won’t be able to reverse engineer this thing once this is done.) I have this in our master database and along with the naming of the proc, don’t need to worry about database context. You can then create a task to run this as often as you like. The dboptions that are being set are necessary unless you want to fill up your logs. The only improvements to this we are implementing is a script on each side of this. The first one drops all indexes and the second one recreates them.

For SQL Server 6.5

Author: Mike Hotek

Download Script:

We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
“as -is”, without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose…

Disclaimer Continued

Back to Database Journal Home

Previous articlesp_ABIndexInfo.sql
Next articleustatprc.sql

Latest Articles