Sunday, March 14, 2010

Process SQL Query On All Database

declare @sqlstring nvarchar(1024)


SET @sqlstring='use ?;DBCC SHRINKFILE (?, TRUNCATEONLY);DBCC SHRINKFILE (?_log, TRUNCATEONLY);BACKUP LOG ? WITH TRUNCATE_ONLY;DBCC SHRINKFILE (?_log, TRUNCATEONLY);';

SELECT @sqlstring;

exec master.dbo.sp_MSforeachDB @command1=@sqlstring

No comments:

Post a Comment