I’m using a SQL Server database in my program with Linq-to-SQL
I’m using this code to empty the database
db.Tb1.DeleteAllOnSubmit(db.Tb1.Select(x => x));
db.SubmitChanges();
After executing this code, everything in the database will be cleared out. But the problem is the size of database didn’t decrease when the rows deleted.
I mean the size of database is still the same after I use that code when it has no data
Sorry for bad English
This is how SQL Server works. The space isn’t returned unless you manually run a “Free unused space” operation on the database, which re-organizes how the records are physically stored in your database file. Otherwise the unused space is kept and reused as new records are added.