top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

When do you use UPDATE_STATISTICS command?

+2 votes
61 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...