Posted - 08/22/2014 : 12:42:24
| I am working in a disposable environment to update a "shrink" script. The script is used to purge "bloat" from the big tables in the Production backup copies we use to refresh instances in our Test environment. The script process involves:
For each selected table (one at a time):
1.Copy the data to be retained to a New table (SELECT * INTO ). These tables are dropped after the process finishes "shrinking" the table.
2.Truncating (vs. deleting records from) the Original table. This is to speed up the process and to prevent bloating the transaction log.
3.Inserting the retained data from the new table into the Original table
4.Dropping the New table
I learned that before I can truncate, I have to work around FKs, Indexes, Constraints, etc. So far I have figured out how to do all of those except SCHEMA BINDING. Our database has a LOTS of views with SCHEMA BINDING.
Question: Is there a way I can remove SCHEMA BINDING from ALL views that reference a selected table without having to:
1.Locate all views with SCHEMA BINDING that refer to a table
2.Script each view to create the view without SCHEMA BINDING
3."shrink" the table
4.Script out all views referring to the table to include SCHEMA BINDING
I am probably asking for the moon, but I thought I would see if anyone else has run into this.
Thanks ahead of time for any help you can provide!
Edited by - tcarnahan on 08/22/2014 12:46:14