locked
Script to swap Mirror and Principle RRS feed

  • Question

  •  

    Is there a way I can swap between the two servers? I currently have server A as principle and Server B as Mirror. I would like it to be the other way around.

     

     

    Wednesday, May 21, 2008 1:12 PM

Answers

  •  

    -- Step 1 on Principal
    alter database <yourdatabase> set partner safety full
    go

     

     

    -- Step 2 on Principal
    Alter database <yourdatabase> SET PARTNER FAILOVER

     

    -- Step 3 on NEW principal
    alter database <yourdatabase> set partner safety off
    go

     

    Wednesday, May 21, 2008 8:20 PM
    Administrator

All replies

  •  

    -- Step 1 on Principal
    alter database <yourdatabase> set partner safety full
    go

     

     

    -- Step 2 on Principal
    Alter database <yourdatabase> SET PARTNER FAILOVER

     

    -- Step 3 on NEW principal
    alter database <yourdatabase> set partner safety off
    go

     

    Wednesday, May 21, 2008 8:20 PM
    Administrator
  • Thanks. Did from the GUI. The failover button does exactly that. But what I am thinking of doing is creating a script that does all of them at once.

     

     

    Friday, May 23, 2008 4:16 PM
  • Probably the easiest way to find out (not only in your case, but in general) what the GUI does, is to run the GUI with SQL Server Profiler also running. In the trace you can see exactly, what's going on and learn a lot!

     

    Monday, May 26, 2008 1:52 PM
  • Unless you have replications streams that also failover, the 3 steps are pretty much what happens when you hit the failover button. But when you do a failover via the gui you need to ensure that your mirroring is synchronous in this case the T-SQL steps does those changes.

     

     

    Tuesday, May 27, 2008 10:13 PM
    Administrator