Answered SMO-how to get the mirror server of a database?

  • יום רביעי 15 פברואר 2012 01:43
     
     
    SMO-how to get the mirror server of a database?  SQL server 2008 R2

    thanks, eric

כל התגובות

  • יום חמישי 16 פברואר 2012 04:27
    מנחה דיון
     
     תשובה

    Hi Eric,

    Since database mirroring is a database level feature, so you can only determine whether a database is mirroring enabled within an instance. In SMO, there is a property named IsMirroringEnabled on database class, which can be used to identify the mirroring.

    In your scenario, you may need to specify the SQL Server instance and loop each database in it to find out the databases enabled mirroring based on the IsMirroringEnabled property. For more information: Database.IsMirroringEnabled Property.
     


    Stephanie Lv

    TechNet Community Support

    • סומן כתשובה על-ידי Eric Chen China יום חמישי 16 פברואר 2012 07:10
    •  
  • יום חמישי 16 פברואר 2012 07:10
     
     תשובה קוד כלול

    thanks.

    Server s = new Server();
    s.Databases[0].MirroringPartner
    s.Databases[0].MirroringWitness
    
    select mirroring_partner_name,mirroring_witness_name from sys.database_mirroring
    
    

    Works.

    thanks, eric

    • סומן כתשובה על-ידי Eric Chen China יום חמישי 16 פברואר 2012 07:11
    •