Wednesday, August 12, 2009

SQL Server server Script which will shrink all databases


DECLARE @cmd1 varchar(2000),
@cmd2 varchar(2000)

SET @cmd1 = 'BACKUP LOG [?] WITH NO_Log'
SET @cmd2 = 'DBCC SHRINKDATABASE ([?],TRUNCATEONLY)'

EXEC sp_msforeachdb @command1 = @cmd1,
@command2 = @cmd2


No comments:

Post a Comment