SQL Server: sp_updatestats to update the Database Statistics

In this post, I am sharing scripts to update a statistic of an individual object or all the objects in SQL Server.

In the query execution process, Query Optimizer uses a statistic of objects to get different information like: number of actual rows, index information, data change count and others.
The database statistic helps to the Query Optimizer in choosing a best execution plan for query processing.

Why object statistic should be updated?

The Query Optimer choose an execution plan accordingly statistical data.
For example, Your table has an actual row count is 100000 and imagine that statistic object is not updated and has only a 50000 row count, so with this situation, it may be selects a wrong execution plan.

To update a Statistic of Tables and Indexes is also one type of maintenance task for DBA and it should be performed periodically.

Update all statistic of a Database:

Update statistic of a Table:

Update statistic of an Index:

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com