Tuesday, August 26, 2014

Shrink all the logs on a server


-- (in conjunction with Mark Nelson)


DECLARE @cmd VARCHAR(6000)

 

SET @cmd = 'USE [?] ;

 

declare @filename varchar(1000), @dbcc varchar(2000)

select @filename = name from sys.sysfiles where filename like ''%ldf''

print @filename

set @dbcc = ''dbcc shrinkfile (xx, 1000)''

set @dbcc = REPLACE(@dbcc, ''xx'' ,@filename)

exec (@dbcc)

'

 

Exec sp_msforeachdb @cmd

No comments:

Post a Comment