Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Email Notification for Transaction log full Expand / Collapse
Author
Message
Posted Friday, November 15, 2013 2:23 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, November 22, 2013 5:34 AM
Points: 58, Visits: 151
How can we get an email notification when db transaction log is full rather than production getting affected. it would be great any script available for the same
Post #1514633
Posted Friday, November 15, 2013 2:29 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 12:20 PM
Points: 41,529, Visits: 34,445
You can create a SQL Agent alert on the appropriate error message. You'll still have the effects of a full log on the DB though.

Why is your log filling often enough for this to be a concern?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1514636
Posted Monday, November 18, 2013 5:33 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 7:44 AM
Points: 1,371, Visits: 2,597
This will alert you when the log usage gets to a certain %, this % amount is up to you.

CREATE procedure sqllogalert                
@database varchar (20),
@threshold int

as

if not exists (select name from sys.databases where name = @database)

begin

print 'Database Does not Exist'

return

end



declare @server varchar(20)

declare @msgtext varchar (200)

declare @profile varchar (10)

set @server = @@servername

set @msgtext = 'SQL ALERT: Database '''+@database+''' On Server: '+@server+' - Transaction Log Usage Above Threshold'

set @profile = 'insert mail profile here'

if exists

(SELECT instance_name as [Database],

cntr_value as "LogFullPct"

FROM sys.dm_os_performance_counters

WHERE counter_name LIKE 'Percent Log Used%'

AND instance_name not in ('_Total', 'mssqlsystemresource')

AND instance_name = @database

and cntr_value > @threshold)

begin

exec msdb.dbo.sp_send_dbmail

@profile_name = @profile,

@recipients = 'insert recipients here',

@subject = @msgtext

end

else

begin

print 'Log File Ok'

end

Execute the procedure like this:

exec sqllogalert
@database = 'database_name'
,@threshold = threshold

Schedule it for as often as necessary
Post #1515192
Posted Tuesday, November 19, 2013 7:14 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, November 22, 2013 5:34 AM
Points: 58, Visits: 151
Thanks a lot for sharing this script.is there option to consider disk space as well since my production log file growing because of full recovery mode.
Post #1515862
Posted Tuesday, November 19, 2013 10:32 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 12:20 PM
Points: 41,529, Visits: 34,445
A properly maintained log should not be growing.

Please read through this: http://www.sqlservercentral.com/articles/Administration/64582/



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1515882
Posted Thursday, November 21, 2013 5:46 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 7:44 AM
Points: 1,371, Visits: 2,597
As Gail pointed out, your log should not be growing. Proper sizing and regular log backups are vital.
Have a read through the link she posted.


If you need to monitor disk space you could look at xp_fixeddrives or sys.dm_os_volume_stats (2008 R2 and above).
Post #1516386
Posted Friday, November 22, 2013 5:44 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, November 22, 2013 5:34 AM
Points: 58, Visits: 151
Thanks a lot for your reply.we have implemented regular log backup and restricted that issue now.
Still we want to avoid log full situation if backup log is not working .Here My production database is running on 2005 version.is there any alternative way for this.
Post #1516740
Posted Friday, November 22, 2013 5:48 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 7:44 AM
Points: 1,371, Visits: 2,597
I would recommend you set up an alert for when log backups are not working. Something that checks when the last log backup was and alerts you if it's more than a certain time ago.

My focus would be to make sure that log backups are running.
Post #1516741
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse