To get an alert when a fail over happened, create a job with following code in the job step
DECLARE @importance AS VARCHAR(6)
DECLARE @body AS NVARCHAR(1000)
DECLARE @Subject AS NVARCHAR(1000)
DECLARE @InstanceName AS VARCHAR(100)DECLARE @NodeName AS NVARCHAR(100)
DECLARE @recipientsList VARCHAR(100)SELECT @recipientsList ='abc@yahoo.com,xyz@gmail.com'
SELECT @InstanceName =@@SERVERNAME
SELECT @NodeName = CAST(SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS NVARCHAR(200))
SELECT @Subject = 'Fail over Happened for Instance '+@InstanceNameSELECT @body = 'Fail over Happened for Instance '+@InstanceName + '. This instance is currently running on the node '+@NodeName
SELECT @importance ='High'
EXEC msdb.dbo.sp_send_dbmail
@profile_name ='MyMailProfile',
@recipients=@recipientsList,
@subject = @subject ,
@body = @body,
@body_format = 'HTML' ,
@importance=@importance
In the schedule pane select schedule Type as "Start Automatically when sql server agent start".
Do this on all instances of the cluster and it is ready . Wait for next fail over. Mail will be there in your inbox.Please be careful that you will get a mail even if the instance got restarted in the same instance or you just stopped and started the agent service. But that can be easily ignored or can be avoid by tweaking the above code little bit.
If you liked this post, do like my page on FaceBook at http://www.facebook.com/practicalSqlDba