Question: What does Keyword STATS Indicates in Backup Scripts in SQL Server?
Answer: This is a very interesting question. I have seen many DBA using the backup scripts and using the keywords STATS but when I ask them if they really know why they are using the keyword STATS, most of the time they have no clue with that.
Let us first see the backup scripts in SQL Server.
BACKUP DATABASE [AdventureWorks2014] TO DISK = N'D:\AW1.bak' WITH FORMAT, STATS = 10 GO
Now the question is what does the keyword STATS do and how it is used.
Well, here is the answer – Stats displays a message of percentage complete when the backup is going on. The default value of the stats is 10 and hence if we do not specify the stats, keywords, SQL Server displays the percentage completion at every 10 percentage.
To further illustrate what I mean by this, let us see a few screenshots where I have changed the STATS value to different values.
I hope from these examples it is very clear to you that STATS displays the progress of the backup complete in SQL Server. For large databases, I prefer to keep the value of the STATS to a much lower value so we can see much finer progress in the message window.
Reference: Pinal Dave (https://blog.sqlauthority.com)
First appeared on What does Keyword STATS Indicates in Backup Scripts in SQL Server? – Interview Question of the Week #138