• I don't think you need to run your process every 30 minutes; you could just create an "autoexec" stored procedure in your master db (see sp_procoption), which runs any time the SQL instance is (re)started (this does get fired when a cluster fails over from one node to the other).

    Mine contain the code snippet below; it doesn't do exactly the same thing you do-- but may do enough, with the benefit of simplicity.

    IF SERVERPROPERTY('IsClustered') = 1

    SELECT nodename,CASE WHEN NodeName = SERVERPROPERTY('ComputerNamePhysicalNetBIOS') THEN 1 ELSE 0 END AS ActiveNode

    FROM sys.dm_os_cluster_nodes

    ORDER BY NodeName


    Cursors are useful if you don't know SQL