获取镜像中涉及的所有服务器
Get All Servers Involved In A Mirror
发布-日期: 2015年10月13日 (评论)
Contents
中文
这里有一些向你展示数据库镜像中涉及的服务器的快速sql逻辑。这不会显示哪个是Principal或Mirror,而只显示服务器名称。查询显示“Server1”和“Server2”加上“Witness”。它主要是为你提供服务器名称。
English
Here’s some quick sql logic to show you the Servers involved in a database mirror. This does not show you which is Principal or Mirror, but only the server names. The query shows “Server1” and “Server2” plus the “Witness”, but that it. It’s meant to give you the Server names.
Logic
use master;
set nocount on
select
[Server1] = @@servername
, [Server2] = replace(reverse(right(reverse(mirroring_partner_name), len(mirroring_partner_name) - charindex('.',reverse(mirroring_partner_name),10) + 0)), 'TCP://', '') , [Witness] = case
mirroring_witness_name
when '' then 'NOT CONFIGURED'
else replace(reverse(right(reverse(mirroring_witness_name), len(mirroring_witness_name) - charindex('.',reverse(mirroring_witness_name),10) + 0)), 'TCP://', '') end
from
master.sys.database_mirroring
where
mirroring_partner_name is not null
Build-Info
Build Quality | Build History | ||||
---|---|---|---|---|---|
Author
- 李聪明的数据库 Lee's Clever Data
- Mike的数据库宝典 Mikes Database Collection
- 李聪明的数据库 "Lee Songming"