92 lines
2.7 KiB
Transact-SQL
92 lines
2.7 KiB
Transact-SQL
BEGIN TRANSACTION
|
|
SET XACT_ABORT ON
|
|
|
|
SELECT srv.name,*
|
|
FROM
|
|
(
|
|
SELECT
|
|
[agents].[subscriber_id]
|
|
,[agents].[subscriber_db]
|
|
,[agents].[subscriber_name]
|
|
,[agents].[publisher_id]
|
|
,[agents].[publisher_db]
|
|
,[agents].[publication]
|
|
,[agents].[subscription_type]
|
|
,[agents].[name]
|
|
FROM [distribution]..[MSdistribution_agents] [agents]
|
|
WHERE [agents].[subscriber_db] IN ( 'Gaia' )
|
|
AND [agents].[anonymous_subid] IS NULL
|
|
) sub1
|
|
INNER JOIN
|
|
(
|
|
SELECT publisher,
|
|
publisher_db,
|
|
publication,
|
|
publication_type,
|
|
agent_name,
|
|
publisher_srvid,
|
|
job_id
|
|
FROM distribution..MSreplication_monitordata
|
|
WHERE publication_id IS NOT NULL
|
|
AND agent_type = 3
|
|
) sub3
|
|
ON sub1.publisher_id = sub3.publisher_srvid
|
|
--AND CAST(sub1.job_id AS UNIQUEIDENTIFIER) = sub3.job_id
|
|
AND sub1.publisher_db = sub3.publisher_db
|
|
AND sub1.publication = sub3.publication
|
|
AND sub1.subscription_type = sub3.publication_type
|
|
AND sub1.name = sub3.agent_name
|
|
JOIN master.sys.servers AS srv
|
|
ON srv.server_id = sub1.subscriber_id;
|
|
|
|
/* update publication server id */
|
|
UPDATE a
|
|
SET [subscriber_id] = s.[server_id]
|
|
FROM [distribution].[dbo].[MSdistribution_agents] a
|
|
CROSS JOIN [sys].[servers] [s]
|
|
WHERE s.[data_source] LIKE '%GALCTP'
|
|
;
|
|
|
|
/* check after */
|
|
SELECT srv.name,*
|
|
FROM
|
|
(
|
|
SELECT
|
|
[agents].[subscriber_id]
|
|
,[agents].[subscriber_db]
|
|
,[agents].[subscriber_name]
|
|
,[agents].[publisher_id]
|
|
,[agents].[publisher_db]
|
|
,[agents].[publication]
|
|
,[agents].[subscription_type]
|
|
,[agents].[name]
|
|
FROM [distribution]..[MSdistribution_agents] [agents]
|
|
WHERE [agents].[subscriber_db] IN ( 'Gaia' )
|
|
AND [agents].[anonymous_subid] IS NULL
|
|
) sub1
|
|
INNER JOIN
|
|
(
|
|
SELECT publisher,
|
|
publisher_db,
|
|
publication,
|
|
publication_type,
|
|
agent_name,
|
|
publisher_srvid,
|
|
job_id
|
|
FROM distribution..MSreplication_monitordata
|
|
WHERE publication_id IS NOT NULL
|
|
AND agent_type = 3
|
|
) sub3
|
|
ON sub1.publisher_id = sub3.publisher_srvid
|
|
--AND CAST(sub1.job_id AS UNIQUEIDENTIFIER) = sub3.job_id
|
|
AND sub1.publisher_db = sub3.publisher_db
|
|
AND sub1.publication = sub3.publication
|
|
AND sub1.subscription_type = sub3.publication_type
|
|
AND sub1.name = sub3.agent_name
|
|
JOIN master.sys.servers AS srv
|
|
ON srv.server_id = sub1.subscriber_id;
|
|
|
|
ROLLBACK TRANSACTION
|
|
|
|
SELECT *
|
|
FROM sys.servers s |