I have a ~ 4 GB database. I copied this database and deleted 99% of the data because I need a database with only the schema and basic data (mostly static data is saved).
Now the problem is that the MDF file is still ~ 4 GB in size. If I read the size of the tables (like this ), they summarize less than 20 MB together. The log file is already compressed, but not one of the scripts that I ran worked to shorten the DB file.
Note. I usually don’t do this, but this time I need to reduce the database (I know this is not recommended)
Edit: + Useful information
Team:
exec sp_spaceused
Conclusion:
database_name database_size unallocated_space
AccudemiaEmptyDb 3648.38 MB 4.21 MB
Team:
select object_name(id) as objname, SUM(dpages*8) as dpages, COUNT(*) as cnt
from sysindexes
group by id
order by dpages desc
Conclusion:
object_name(id) sum(dpages*8) count(*)
sysdercv 675328 1
sysxmitqueue 359776 1
sysdesend 72216 1
sysconvgroup 47704 1
sysobjvalues 4760 5
sec_OperationAccessRule 3472 5
sec_PageAccessRule 2232 5
syscolpars 656 11
AuditObjects 624 2
sysmultiobjrefs 408 5
HelpPage 376 8
sysschobjs 352 9
syssoftobjrefs 328 7
sysidxstats 272 10
sysrscols 200 1
Translation 160 3
sysallocunits 128 3
sysiscols 128 8
syssingleobjrefs 96 5
sysrowsets 80 4