top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

When do you use UPDATE_STATISTICS command?

+2 votes
329 views
When do you use UPDATE_STATISTICS command?
posted Sep 26, 2014 by Deepak Negi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Updating the statistics of all the tables regularly in your SQL Server Database is an integral part of Database Maintenance. This can be achieved in many ways. We can do this through a script or create a sql job scheduled to run at a certain time.

To determine whether an index has it's stats updated we can run the following command:

DBCC SHOW_STATISTICS (table_name , index_name)

To Update the Stats on a table the following command can be run :

UPDATE STATISTICS <table name> WITH FULLSCAN

The above command will scan all the rows of the table to get the updated statistics.

UPDATE STATISTICS <table name> WITH SAMPLE 50 PERCENT

The above script can be run for very large tables in case we want to specify a percentage of the total no of rows.

answer Oct 3, 2014 by Amit Kumar Pandey
...