Today I am going to share very small yet very useful and handy script. It is often necessary to keep update statistics of all tables for performance point of view. Actually by default query optimizer updates statistics in query plan in certain situation but it is good to manually do it to assure that every query plan it optimized and up-to-date.
You can generate T-SQL for update statistics for all tables of your database along with Schema name. Have a look at the script.
‘UPDATE STATISTICS ‘ + SysSche.Name + ‘.’ + SysObj.Name
sys.schemas SysSche ON SysObj.Schema_ID = SysSche.Schema_ID
TYPE = ‘U’
For more details about UPDATE STATESTICS and its syntax, you can refer official Microsoft link at