What's the ideal (or necessary) sequence of call when restoring a SQL Server 2012 backup onto a SQL Server 2014 instance and updating the compatibility level?
-- Update Statistics for all tables
EXEC sp_MSforEachtable 'Update Statistics ? with FULLSCAN';
-- Update page and row counts in catalogviews
DBCC UPDATEUSAGE('MY_DATABASE') ;
-- Change DB Compatibility level
EXEC sp_dbcmptlevel 'MY_DATABASE', '120';
I'm not sure if the db compatibility level effects the stats or simple the engine on the server. If the db compatibility level influences stats than it should be done before update stats. Also unclear if UPDATEUSAGE is still recommend and if it should be before update stats as well.