adminbd

Записи по mssql,oracle,windows и linux

Have a Question?

If you have any question you can ask below or enter what you are looking for!

Сжать лог у всех баз на сервере

--select * from [master].[sys].[databases]

--where not name in ('master','tempdb','model','msdb')

 

declare @name nvarchar(512)

declare @cmd nvarchar(512)

DECLARE @Cursor CURSOR

SET @Cursor = CURSOR FOR

select   name from [master].[sys].[databases]

where not name in ('master','tempdb','model','msdb')

 

 

 

OPEN @Cursor

FETCH NEXT FROM @Cursor INTO @name

 

WHILE (@@FETCH_STATUS = 0)

BEGIN

--print @name

 

set @cmd = 

'USE ['+@name+']

GO

DBCC SHRINKFILE (N'''+@name+ '_log'', 0, TRUNCATEONLY)

GO'

 

print @cmd

--exec (@cmd)

 

FETCH NEXT FROM @Cursor INTO @name

end

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>