Here’s a simplified version of my previous datafile resizing helper script. I tend to resize most datafiles to 30%free on Friday afternoons for resilience over the weekend 😉
--datafile_resize.sql create table #filestats (fileid int, fg int, AllocatedSpace int, UsedSpace int, dfile varchar(200), DataFile varchar(200)) insert into #filestats exec('dbcc showfilestats') update #filestats set AllocatedSpace = AllocatedSpace * 0.0625, UsedSpace = UsedSpace * 0.0625 select DataFile, AllocatedSpace, UsedSpace, cast(cast(AllocatedSpace - UsedSpace as numeric) / AllocatedSpace * 100 as int) [Free%], cast(UsedSpace * 1.449 as int) [Plus30%] from #filestats -- where datafile like 'E%' -- e-drive only order by [free%] drop table #filestats