• a better solution (can even be done in GUI if you don't want write code :-D):

    - add a new file to the filegroup

    - run DBCC ShrinkFile on the original file with the EMPTYFILE-Option -> this will move all (used) pages from the original file to the new one

    - now you can either drop the original file

    - or (if you prefer to still use it, e.g. because DBCC reported that it could not move all data) run a usual SHRINKFILE on the original again (because the filesize will not be reduced if DBCC gives this error)

    - run DBCC ShrinkFile with EMPTYFILE on the new file -> moves the data back to the original file

    - drop the new file

    - repeat if you have more than one filegroup and have to shrink the other ones too

    Used this methode few minutes ago to shink my msdb from about 2 GB to 400 MB