exec sp_MSforeachdb ' use [?] declare cur cursor for select name from sys.database_files where type_desc = ''LOG'' declare @nm nvarchar(max) declare @cmd nvarchar(max) = '''' open cur fetch next from cur into @nm while @@FETCH_STATUS = 0 begin set @cmd = ''DBCC SHRINKFILE ('''''' + @nm + '''''', 2)'' print @cmd exec (@cmd) fetch next from cur into @nm end close cur deallocate cur' |
sql | SQL Server > sqlsrv | T-SQL >