• Here is my script - it isn't perfect, i wrote it when i was frustrated and wanted to get it out right away, you'll probably want to change it depending on how your environment is set up:

    CREATE PROCEDURE [Monitor].[ClusterFailover] @recipients nvarchar(max)= 'xyz'

    AS

    /*********************************************

    runs when SQL Agent starts up and determines the node

    on which SQL is running and alerts the dba team to failover

    This way we know when a server fails over

    Created:5/7/2012

    Created By:Amanda Bates

    Modified6/5/2012

    ****************************************/

    Declare

    @subject nvarchar(200),

    @body nvarchar(max),

    @query nvarchar(max),

    @execute_query_database sysname,

    @ClusterName nvarchar(50),

    @ClusterNode1 nvarchar(50),

    @CurrentNode nvarchar(50),

    @ClusterNode2 nvarchar(50)

    SELECT @ClusterName = @@Servername

    SELECT @CurrentNode = CONVERT(nvarchar(50), ServerProperty('ComputerNamePhysicalNetBIOS') )

    SELECT @ClusterNode1 = MIN(NodeName) FROM sys.dm_os_cluster_nodes

    SELECT @CLusterNode2 = MAX(NodeName) FROM sys.dm_os_cluster_nodes

    SELECT @subject = @ClusterName + ' Failover Or Restart!'

    SELECT @body = @ClusterName + ' ' + 'is now running on node '+ @CurrentNode + ' Nodes: '+ @ClusterNode1 + '/' + @ClusterNode2

    EXEC msdb.dbo.sp_send_dbmail

    @recipients= @recipients,

    @subject = @Subject,

    @body = @body

    GO

    and then you do this:

    ALTER PROCEDURE [dbo].[Startup_procs] AS

    /************************************

    this stored procedure runs when the server starts, and executes

    the below stored procedure.

    Created: 5/1/2012Amanda Bates

    ************************************/

    EXEC Monitor.ClusterFailover

    ----this sends an email indicating the server is coming back up after

    ----an outage. it will also include the name of the node it is on

    ----email addresses are hard-coded into the sub-proc

    GO

    EXEC sp_procoption N'[dbo].[Startup_procs]', 'startup', '1'

    GO

    I was lazy or i would have figured out a way to make the email addresses dynamic.