-- first cleanup the log file then reduce the db to 10% free space sp_msforeachdb 'use ? set nocount on if db_name() not in (''master'',''model'',''msdb'',''tempdb'') begin select ''use '' + db_name() + '' dbcc shrinkfile('''''' + rtrim(name) + '''''',truncateonly) GO-- dbcc shrinkdatabase('''''' + db_name() + '''''',10) GO--'' from sysfiles where groupid = 0 end'