I have a database which is ~4GB in size. I've copied that database and deleted 99% of the data on it because I need a database with only the schema and basic data (mostly static data is kept).
The problem now is that the MDF file still is ~4GB in size. If I read the size of the tables (using this, for example), they sum less than 20 MB all together. The log file is already shrunk, but none of the scripts I ran worked for shrinking the DB file.
Note: I usually don't do this, but this time I need to shrink the database (I know it's not recommended)
Edit: +Useful info
Command:
exec sp_spaceused
Output:
database_name database_size unallocated_space
AccudemiaEmptyDb 3648.38 MB 4.21 MB
Command:
select object_name(id) as objname, SUM(dpages*8) as dpages, COUNT(*) as cnt
from sysindexes
group by id
order by dpages desc
Output:
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