adminbd

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

Have a Question?

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

Хранимая процедура для архивирования журнала при достижении @danger_value.

declare @tran_log_space_usage table( 
        database_name sysname
,       log_size_mb float
,       log_space_used float
,       status int
); 
declare @log_space_used float	-- Доля (в процентах) файла журнала, в настоящее время заполненная
declare @danger_value int		--  Значение в Мб, при достижение которого архивируется журнал
declare @job_start_name sysname
 
set @danger_value = 7000
set @job_start_name = N'SSAS_LSBackup_ax_molniya'
 
insert into @tran_log_space_usage 
exec('DBCC SQLPERF ( LOGSPACE )') ; 
 
set @log_space_used = (
select (log_space_used * log_size_mb / 100)  from @tran_log_space_usage
where database_name = DB_NAME() 
)
 
if (@log_space_used > @danger_value)
begin
EXEC msdb.dbo.sp_start_job @job_start_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>