20100315

Shrinking MSSQL log files

Best solution I've found below.
You just have to replace XYZ with database name in few places.
You can also uncomment print to get filename.
Yes, I know it would be useful to have version that iterates through all the databases - I'm just too lazy.

alter database XYZ set recovery simple
GO
alter database XYZ set recovery full
GO
use XYZ
GO
declare @filename sysname
select @filename=Name from sys.database_files where Type=1
--print @filename
DBCC Shrinkfile(@filename,100) 
GO
alter database XYZ set recovery bulk_logged
GO

No comments: