Courtesy of Nayan Raval & #SQLHelp, which led me to another article (http://blogs.solidq.com/fabianosqlserver/post.aspx?id=52&title=undocumented+option(querytraceon+%3Ctracenumber%3E)+and+trace+flags+2388%2C+2389%2C+2390) which documents 2 more undocumented trace flags.
How do you find out when statistics were created? If it's on an indexed field, when the index was created (crdate in sys.indexes). But statistics on non-indexed fields? Using Trace Flag 2388 changes the information that SHOW_STATISTICS returns.
DBCC TRACEON (2388)
DBCC SHOW_STATISTICS ('yourtablename','_WA_Sys_x')
DBCC TRACEOFF (2388)
And there's another use for this trace flag... when, aside from the most-recent date, was a statistic updated? STATS_DATE will show you the LAST time it was updated, but I recently had a problem where I knew the problem existed and quickly updated stats, then realized I wanted to know when BEFORE then it had been updated. One search to my blog later, code found, and there we go.
No comments:
Post a Comment