DECLARE @cmd VARCHAR(6000)
SET @cmd = 'USE [?] ;
declare @filename varchar(1000), @dbcc varchar(2000), @alter
varchar(1000), @size int
select @filename = name, @size = (size+127)/128 from sys.sysfiles
where filename like ''%ldf''
print db_name()
print @filename
set @dbcc = ''dbcc shrinkfile (xx, 2)''
set @dbcc = REPLACE(@dbcc, ''xx'' ,@filename)
set @alter = ''ALTER DATABASE ['' + db_name() +
''] MODIFY FILE ( NAME = xx, SIZE = '' + convert(varchar, @size ) +
''MB, FILEGROWTH = 10%)''
set @alter = REPLACE(@alter, ''xx'' ,@filename)
print @dbcc
print @alter
exec (@dbcc)
exec (@alter)
'
Exec sp_msforeachdb @cmd