In a system there is a nightly data load process where all the foreign keys are dropped, all tables are truncated, repopulated from an external source, and the foreign keys are put back in place.

At the end of this process I would expect sp_updatestats to run, so that statistics for all this new data is updated.

However, while inspecting the code I noticed the following line instead:


Can you compare that with running sp_updatestats? That is what is the differences and advantages/disadvantages of one over the other?


1 Answer 1


Couple of things ..

  1. Stop using the undocumented sp_MSforeachtable
  2. From Erin's blog - Understanding What sp_updatestats Really Updates

    sp_updatestats updates only the statistics that require updating based on the rowmodctr information in the sys.sysindexes catalog view, thus avoiding unnecessary updates of statistics on unchanged rows

Note that sp_updatestats in the code sp_helptext sp_updatestats, it runs 'UPDATE STATISTICS '

enter image description here


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.