一般我们可以为某段设置多个阀值,但只需在达到最后机会阀值时作些空间清理的操作.
第一步,在你的数据库中设置阀值,并指定达到阀值后的处理过程:
查看当前数据库某段的最后机会阀值:
sp_helpthreshold "default"
或者察看其他段的信息。
修改某段的最后机会阀值:
sp_modifythreshold 数据库名,段名,自由空间名,[新过程名[,新自由空间名[,新段名]]]
sp_modifythreshold mydb,"default",200,NULL,175
将最后机会阀值由200页调整到175页。
具体其他操作,可以参考相关手册!
第二步,编写阀值处理过程:
create procedure sp_thresholdaction
@dbname varchar(30),
@segmentname varchar(30),
@space_left int,
@status int
as
declare @SpaceLeft varchar(20),
@Status varchar(20)
select @SpaceLeft=str(@space_left,6,0)
select @Status=str(@status,6,0)
print "Log is dumpped('%1!' for '%2!',SpaceLeft:'%3!',Status:'%4)',
and is dumped.",@segmentname,@dbname,@SpaceLeft,@Status
dump transaction tempdb to with truncate_only
return
不过,我还是不建议用最后机会阀值来进行自动维护。
没有评论:
发表评论