Reputation: 13306
We've been trying to alter a lot of columns from nullable to not nullable, which involves dropping all the associated objects, making the change, and recreating the associated objects.
We've been using SQL Compare to generate the scripts, but I noticed that SQL Compare doesn't script statistic objects. Does this mean its ok to drop them and the database will work as well as it did before without them, or have Red Gate missed a trick?
Upvotes: 5
Views: 6904
Reputation: 135021
If you have update stats and auto create stats on then it should works as before
You can also run sp_updatestats
or UPDATE STATISTICS WITH FULLSCAN
after you make the changes
Upvotes: 2
Reputation: 38406
It is considered best practice to auto create and auto update statistics. Sql Server will create them if it needs them. You will often see the tuning wizard generate lots of these, and you will also see people advise that you update statistics as a part of your maintenance plan, but this is not necessary and might actually make things worse, just so long as auto create and auto update are enabled.
Upvotes: 2
Reputation: 15769
Statistics are too data-specific to be tooled. It would be potentially very inefficient to blindly re-create them on a data set.
Upvotes: 0
Reputation: 15568
Why are you dropping objects? Seems to me the sequence should be a lot simpler, and less destructive: assign all of these objects a default value, then make the change to not nullable.
Upvotes: 1