This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing the usage of sp_clean_db_free_space system stored procedure to remove the ghost records from the SQL Server.
Whenever we are deleting or updating the records, internally, it doesn’t eliminate physical rows immediately.
After update/delete DML operations, it requires to free up space from the page by removing the reference of records.These types of records called as Ghost records, and the background process will remove it.
Now imagine that you update/delete billions of data and right after that going to take database backup. There might be a chance that default background process of removing Ghost records didn’t execute yet so your backup might create with ghost records.
Here, you can use sp_clean_db_file_free_space to remove all ghost records of the database.
Sample:
1 2 3 4 |
USE master; GO EXEC sp_clean_db_free_space @db_name = N'Database_Name' |