An example: scheduling and rescheduling a failover

You can execute an administrative failover for a cluster or an instance. The cluster or instance fails over to previously configured failover resources.

In this example, we fail over the “SalesLC” cluster, scheduling the failover for 2 a.m. So that we can later track or change the action, we also include the syntax that outputs an action handle:

declare @out_handle varchar(15)

execute
sp_cluster logical, "failover", SalesLC, cluster, NULL, until, "02:00:00", @handle = @out_handle output

Suppose the command outputs the action handle “1234”, and SalesLC enters the time_wait state. All new connections migrate to the failover resources. Any existing connections remaining after 2 a.m. are terminated, and “SalesLC” enters the offline state.

Suppose we find that we must migrate all connections immediately. We can use the action handle to reschedule an immediate failover. Enter:

sp_cluster logical, "failover", SalesLC, modify_time, "1234", nowait