views:

621

answers:

7

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?

+1  A: 

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.

DannySmurf
A: 

Statistics are too data-specific to be tooled. It would be potentially very inefficient to blindly re-create them on a data set.

Stu
+1  A: 

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

SQLMenace
A: 

The statistics objects that exist were created many moons ago by someone else using the database tuning wizard. Are they then safe to delete and just use the auto ones?

mcintyre321
A: 

The statistics objects that exist were created many moons ago by someone else using the database tuning wizard. Are they then safe to delete and just use the AUTO ones?

You are talking about those silly named views? Yes you can drop those

SQLMenace
A: 

There are lots of statistics objects called things like _WA_Sys_ObjectK_61F08603 - not view objects. Are those what you mean?

mcintyre321
A: 

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.

Eric Z Beard