When migrating a database, do we need to script out statistics?
Statistics are important for performance and are essential for the query optimizer to prepare an optimized and cost-effective execution plan. So I think we need to script out statistics when migrating.
If you migrate database using backup file, then we don’t need to script out statistics cause the statistics are included in the .bak file.
You can right-click on the database name -> Tasks -> select Generate Scripts in the SSMS.
In the Set Scripting Options tab, click Advanced and set script statistics to Script statistics and histograms.
Please refer to this article which might be helpful.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
14 people are following this question.