Can anyone suggest some SQL to get a list of filegroups that are 10% bigger than they need to be?
What I'm trying to do:
I have a set of tables, one per month, each on their own filegroup. I deliberately create the filegroup oversized because during the first three months they may at times contain two copies of the table (that's the way the application works).
However, after the data is 3 months old I want to the application to shrink the filegroup (using only T-SQL).
I've written some SQL to return a list of all tables with data older than 3 months, but I only want to run DBCC SHRINKFILE on tables/filegroups that are, say, 10% bigger than they need to be.